Transforms

A dataset Transform function is a transformation hook. This is an optional event handler that can be set on a dataset to make modifications to the data returned from the call to a data service before the change is broadcast to consumers.

Note, the Transform function was called View in earlier versions of WireBootstrap.

In the example below, the data retrieved from the data service call is passed into the transform inside a configuration object as a data table. A new column is added and the table is returned to the dataset in the callback.

...
    
const dataset = new wire.data.DataSet({
    Source: accountService,
    Query: query,
    Transform: (config, callback) => {
        
        //
        // config.table is a DataTable
        //
        const table = config.table;
        
        //
        // add a new column to the table 
        //
        table.addColumn("FullName").calc((row) => {
            return row.FirstName + " " +  row.LastName;
        });
        
        //
        // tell the dataset we are done 
        // sending back the updated data table
        //
        callback(table);     
    }
});

For more on data set transforms, visit the DataSet reference page.

Last updated