This section show how rows can be added, removed and updated using the Server-Side Transaction API.
Server-Side Transactions require Row ID's to be supplied to grid.
The SSRM Transaction API allows rows to be added, removed or updated in the grid:
These operations are shown in the snippet below:
this.gridApi.applyServerSideTransaction({
add: [
{ tradeId: 101, portfolio: 'Aggressive', product: 'Aluminium', book: 'GL-62472', current: 57969 }
],
update: [
{ tradeId: 102, portfolio: 'Aggressive', product: 'Aluminium', book: 'GL-624723', current: 58927 }
],
remove: [
{ tradeId: 103 }
]
});
The following example demonstrates add / update and remove operations via the Server-Side Transaction API. Note the following:
addIndex
property as rows are added at the end by default.To use transactions while using row grouping, transactions need to be applied to the specific row group. This is done by providing a route
when applying the transaction. It is also necessary to inform the grid when group rows are updated, added or removed.
The snippet below demonstrates creating a group row transaction for rows which are the first of their group, as the leaf rows will be requested via getRows
when the group is expanded.
// create the group row at the root level (only if it's the first row for this group)
this.gridApi.applyServerSideTransaction({
route: [],
add: [{ portfolio: 'Aggressive' }]
});
// otherwise, create the leaf node inside of the 'Aggressive' group
this.gridApi.applyServerSideTransaction({
route: ['Aggressive'],
add: [row]
});
In the example below, note the following:
When processing many updates rapidly, the grid will perform more smoothly if the changes are batched (as this can prevent excessive rendering). The grid can batch these changes for you without negatively impacting the user experience, and in most cases improving it.
When using asynchronous transactions, the grid delays any transactions received within a time window (specified using asyncTransactionWaitMillis
) and executes them together when the window has passed.
The snippet below demonstrates three asynchronous transactions applied sequentially, however because these transactions are asynchronously batched, the grid would only update the DOM once.
// due to asynchronous batching, the following transactions are applied together preventing unnecessary DOM updates
this.gridApi.applyServerSideTransactionAsync({
add: [{ tradeId: 101, portfolio: 'Aggressive', product: 'Aluminium', book: 'GL-62472', current: 57969 }],
});
this.gridApi.applyServerSideTransactionAsync({
update: [{ tradeId: 102, portfolio: 'Aggressive', product: 'Aluminium', book: 'GL-624723', current: 58927 }],
});
this.gridApi.applyServerSideTransactionAsync({
remove: [{ tradeId: 103 }],
});
In the example below, note the following:
The following demonstrates a more complex example of transactions, it shows subscribing to a source of updates to provide the changes, while using dynamic row grouping, aggregation, and child counts. All of which react to the changes caused by the transactions.
In the example below, note the following:
Transactions are also supported when using tree data. See this documented on the SSRM Tree Data page.
Continue to the next section to learn about Load Retry with the SSRM.