When WireBootstrap makes a call to the server from a client for data, that data is returned in a powerful JavaScript object called a DataTable.  This DataTable holds the records returned from the query as an array of objects.  It contains methods and properties for manipulating these records in memory.  Operations include:


  • Filtering, selecting, and sorting data
  • Creating new calculated columns
  • Aggregating data
  • Creating or deleting rows
  • Joining to data in other DataTables
  • Returning individual or groups of records



Example


In the example below, a new instance of a DataTable is created from an array of objects.  The DataTable class is in a namespace called eb.data  A new calculated column is then created by referencing existing columns.


var data = [ 
    {product: "apples", order: "PRN001", quantity: 10},
    {product: "oranges", order: "PRN002", quantity: 15},
    {product: "apples", order: "PRN003", quantity: 20}
];
 
// create a new table from an array of objects
var table = new eb.data.DataTable(data);
 
// create a new calculated column
table.addColumn("More Apples").calc(function(row) {
    if(row["product"] == "apples")
        return row["quantity"] * 10;
    else
        return row["quantity"];
});