wire.data.DataTable

Properties

A data table holds an array of objects in the Rows property much like the rows in a relational database table. Each property in the object has a column that stores meta data about the property in the Columns property.

Create a new data table by passing in an array of rows and an optional list of columns. If the columns aren't passed in, they will be created from the rows automatically.

let rows = [
    { UserName: "apeters", FullName: "Amy Peters", Quota: 1000, Active: true},
    { UserName: "jross", FullName: "John Ross", Quota: 1500, Active: true }    
]

let table = new wire.data.DataTable(rows);

Methods

Select Methods

Use the select method in order to select data from the data table. The select method can take an optional list of comma delimited fields to be selected.

Select Aggregate Methods

Select the UserName column from the data table. Also select the FullName field but change its name to DisplayName. Aggregate the Quota column using a sum and format it to a whole number with no decimals which will include thousand separator commas. The result will automatically be grouped by UserName and DisplayName.

table.select("UserName")
    .column("FullName").as("DisplayName")
    .sum("Quota").format("N0");

Filter Methods

Start a filter chain using the where method.

Filter the data table to UserName equal to apeters but only if her Quota is greater than 800.

table.select().where()
    .eq("UserName", "apeters")
    .filter((row, index, rows) => {
       return row.Quota > 800; 
    });

Evaluation Methods

Once fields are selected and filtered, use the following methods to evaluate the resulting rows.

The following creates a new data table with just the UserName field from the original data table.

let newTable = table.select("UserName").table();

Visit Working with DataTables for more details and examples on using data tables.

Last updated