Grid Mode
- 3 minutes to read
The ExpressQuantumGrid performance when loading data from datasets depends on several factors:
The number of records loaded;
The number (and size) of fields in each record loaded;
The database server’s location.
If any of these factors cause insufficient application performance, the ExpressQuantumGrid should be used in server mode or grid mode.
When using grid mode, the data controller loads a fixed number of dataset records into memory. The number of records to be loaded depends on the GridModeBufferCount property value. A user is permitted to perform data-related operations on the loaded records only. The automatic sorting, filtering, summary calculations and smart refresh features are not supported in grid mode. These features need to be handled manually by handling the appropriate events of the data controller.
To activate grid mode, set the data controller’s GridMode property to True. This data controller mode is deactivated though when you group records within a View. In this case, the data controller switches to default data loading mode.
There is an issue concerning scrolling records in grid mode. Most dataset tables support sequence numbers (sequence numbers can also be computed by dataset components). See the TDataSet.IsSequenced function to test whether sequence numbers are available. If IsSequenced is True, applications can safely use the RecNo property to navigate dataset records.
If sequence numbers are available for a dataset displayed in grid mode, there is a unique correspondence between the position of the scrollbar’s thumb and the record number. So you can drag the thumb to scroll the View to locate a specific record.
If sequence numbers are not available, the grid control cannot determine the position of the current record relative to the beginning or end of the dataset. That is why the scrollbar’s thumb cannot reflect the absolute position of the current record.
However, in some cases the grid control cannot display the scrollbar’s thumb correctly in grid mode even if sequence numbers are available in the dataset. To support sequence numbers in grid mode, the following conditions must be observed:
Records within a corresponding View must be of the same height (the OptionsView.CellAutoHeight property must be set to False or the OptionsView.DataRowHeight property must be set to a non-zero value);
The height of the preview section must not be calculated automatically based on the length of a corresponding field (the Preview.AutoHeight property must be set to False);
The View must not be a master View.
By default, the ExpressQuantumGrid data controller loads all records from a dataset. This mode was called LoadAllRecords in ExpressQuantumGrid3. In this mode, all data controller features (automatic sorting, filtering and summary calculations) are available. The SmartRefresh feature is also available in this mode. This option increases the ExpressQuantumGrid performance by reloading only changed dataset records when updating. Using SmartRefresh imposes some restrictions on the dataset:
The key field should exist;
All changes to data should be performed via ExpressQuantumGrid.
The SmartRefresh feature is effective if the dataset’s size exceeds 1000 records. Otherwise, you should disable it.
Refer to the Grid Mode: Master-Detail topic for information on how to create master-detail relationships in grid mode.