Use the View tab on the DataSet step to transform data returned from the server query before sending the results to the presentation layer in the system.  This advanced feature requires at least a basic understanding of JavaScript.



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


For details visit the DataTables Reference.  


View Function


/*
  data.table -> data table returned from the server
  data.config -> configuration object passed into data set during UI binding if any
  data.dataset -> this dataset
  callback -> asynchronous callback function to return data
*/


Data supporting both the query and the result set are stored in the data object passed to the anonymous View function. This object can be used to access the result set and make any changes needed. Once these changes are ready, call the asynchronous callback function to pass the new result set back to the system pipeline.


PropertyDescription
data.tableThe DataTable containing the result set
data.configUndocumented system object
data.datasetUndocumented system object
callbackAsynchronous function called to pass the updated DataTable to the pipeline context


Example


function(data, callback) {

/*
  data.table -> data table returned from the server
  data.config -> configuration object passed into data set during UI binding if any
  data.dataset -> this dataset
  callback -> asynchronous callback function to return data
*/

  // add debugger break for debugging (optional)
  debugger
  
  // create a new column in result set called Profit that is calculated
  // from two fields returned from the server query - Sales and Cost
  data.table.addColumn("Profit").calc(function(row){
    return (row.Sales - row.Cost);    
  });

  // return the updated table
  callback(data.table);

}