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.
1
...
2
3
const dataset = new wire.data.DataSet({
4
Source: accountService,
5
Query: query,
6
Transform: (config, callback) => {
7
8
//
9
// config.table is a DataTable
10
//
11
const table = config.table;
12
13
//
14
// add a new column to the table
15
//
16
table.addColumn("FullName").calc((row) => {
17
return row.FirstName + " " + row.LastName;
18
});
19
20
//
21
// tell the dataset we are done
22
// sending back the updated data table
23
//
24
callback(table);
25
}
26
});
Copied!
For more on data set transforms, visit the DataSet reference page.
Copy link