Vue Data Grid: Client-Side Data - High Frequency Updates
High Frequency Updates relates to lots of updates in high succession going into the grid. Every time you update data in the grid, the grid will rework all aggregations, sorts and filters as well as having the browser update its DOM. If you are streaming multiple updates into the grid this can be a bottleneck. High Frequency Updates are achieved in the grid using Async Transactions. Async Transactions allow for efficient high-frequency grid updates.
When you call
applyTransactionAsync() the grid will execute the update, along with any other updates you subsequently provide using
applyTransactionAsync(), after 50ms. This allows the grid to execute all the transactions in one batch which is more efficient.
To help understand the interface for
applyTransactionAsync(), here are both method signatures side by side. The first executes immediately. The second executes sometime later using a callback for providing a result.
// normal applyTransaction takes a RowDataTransaction and returns a RowNodeTransaction applyTransaction(rowDataTransaction: RowDataTransaction): RowNodeTransaction // batch takes a RowDataTransaction and the result is provided some time later via a callback applyTransactionAsync(rowDataTransaction: RowDataTransaction, callback?: (res: RowNodeTransaction) => void): void
Use Async Transactions if you have a high volume of streaming data going into the grid and don't want the grid's rendering and recalculating to be a bottleneck.
You might ask, wouldn't using a virtual DOM like React remove the necessity of Async Transactions? The answer is no. A virtual DOM would only batch the DOM related updates, it would not help with the batching of aggregations, sorts and filters.
Each time the grid executes a batch of Async Transactions, it dispatches a
The event contains
results attribute, which is a list of all the results for all Transactions that got applied.
This event is useful for debugging or observing how the Async Transactions are applied for learning purposes.
The default wait between executing batches is 50ms. This means when an Async Transaction is provided to the grid, it can take up to 50ms for that transaction to be applied.
Sometimes you may want all transactions to be applied before doing something - for example you may want to select a row in the grid but want to make sure the grid has all the latest row data before doing so.
To make sure the grid has no Async Transactions pending, you can flush the Async Transaction queue. This is done by calling the API
It is also possible to change the wait between executing batches from the default 50ms. This is done using the grid property
The example below demonstrates setting the wait time and also flushing. Note the following:
- The property
asyncTransactionWaitMillisis set to 4000, thus transactions get flushed every 4 seconds.
- The button Flush Transactions will call the API method
- Transactions getting added and executed is logged to the console.
- The example listens on event
asyncTransactionsFlushedand logs how many transactions got applied.