You are viewing help content for pre-release software. This document and the features it describes are subject to change. Switch to the current version.

Frequent Data Updates

  • 4 minutes to read

You can use one of the following techniques to optimize data updates within the GridControl:

  • Speed up individual updates
  • Process updates in batches

View Example: How to Effectively Process Data Updates in WPF GridControl

Speed Up Individual Updates

ChunkList

The ChunkList<T> suits applications where you handle large collection updates. The ChunkList might work slower than ordinary collections if you perform multiple operations that iterate over data source items (for example, summary calculation, data sort and filter operations).

We recommend that you use the ChunkList in the following case:

  • The data source contains at least 10,000 elements.
  • One update operation affects a batch of elements in a collection.

Optimized Summaries

The GridControl recalculates all records to update data summaries. To optimize an update operation, set the GridControl.OptimizeSummaryCalculation property to true. In this case, the GridControl calculates values only for changed records and updates data summaries according to these values. Therefore, the performance does not depend on the number of records.

We recommend that you optimize summary calculation in the following case:

Process Updates in Batches

Data shaping operations allow you to sort, filter, and group data, and calculate summaries. The GridControl performs these operations when a data source change occurs. To process multiple updates as a single action, use one of the following methods:

Lock GridControl Updates

When you lock updates within the GridControl, a user cannot perform any data operations in the UI. You can process data updates and then apply all changes to the GridControl.

We recommend that you lock GridControl updates in the following case:

  • Your data source contains less than 100,000 elements. If the data source is too large, visible UI lags might appear.

  • A batch accumulates multiple updates.

Follow the steps below to apply this technique:

  1. Call the BeginDataUpdate method to lock data updates in the GridControl.
  2. Process multiple updates.
  3. Call the EndDataUpdate method to apply the changes.

The code sample below demonstrates how to prevent the GridControl from frequent updates when multiple data changes occur.

public void PerformUpdates() {
    gridControl.BeginDataUpdate();
    // Perform massive data updates...
    gridControl.EndDataUpdate();
}

Refer to the following example if you want to call the BeginDataUpdate and EndDataUpdate methods in a MVVM application:

View Example: How to Call the BeginDataUpdate and EndDataUpdate Methods at the View Model Level

Lock TreeListView Updates

If you use the TreeListView, the GridControl processes updates according to the data structure type:

Self-Referential
The GridControl ignores notifications from the data source and recreates nodes after an EndDataUpdate() call. If you process few updates, you can update nodes in real time to improve performance. To do this, call the TreeListView.BeginDataUpdate(bool recreateNodesOnEndDataUpdateOnly) method and pass false as a parameter.
Hierarchical
The GridControl handles notifications from the data source and updates nodes after each change. If you process massive updates, you can recreate nodes after an EndDataUpdate() call to improve performance. To do this, call the TreeListView.BeginDataUpdate(bool recreateNodesOnEndDataUpdateOnly) method and pass true as a parameter.

Manual Refresh

Set the AllowLiveDataShaping property to false to allow the GridControl to ignore data shaping operations when data is changed. Call the RefreshData method to display all changes in the control.

We recommend that you force GridControl updates manually in the following case:

  • You store data in the List<T> collection.
  • Your data source contains less than 100,000 elements. If your source is too large, visible UI lags might appear.
  • You refresh the GridControl on demand, but not after each change in the data source.

Automatic Refresh on a Timer

If your data changes frequently (for example, each millisecond), the GridControl does not have enough time to update its layout. You can perform the update operation on a timer. Implement a custom collection that blocks notifications about changes from the data source and copies data in the specified time interval. Changes in this collection trigger GridControl updates. Refer to the following example:

View Example: Data Grid for WPF - How to Refresh the Data Grid on a Timer

We recommend that you update data on a timer in the following case:

  • Your data source contains less than 100,000 elements. If your source is too large and visible UI lags occur, you can increase the interval.
  • You refresh the GridControl periodically, but not after each change in the data source.
See Also