TMS TDBAdvGrid & PageMode
-
TDBAdvGrid with PageMode property set true
This is the default mode for TDBAdvGrid. With PageMode = true, the behaviour of TDBAdvGrid most closely resembles the behaviour of the standard VCL TDBGrid. This means that TDBAdvGrid only loads the rows from the connected dataset that are visible. The grid will load a new page of rows when it is scrolled to a previous or next page. As the grid loads the minimum number of rows that is simultaneously required for display, this is the fastest mode. A disadvantage of this mode is that not all rows are simultaneously available for operations like searching, grouping, filtering, sorting, export, printing,... - TDBAdvGrid with PageMode property set false
When PageMode is false, all rows of the dataset are loaded in the grid when the dataset is activated. This can have an initial performance hit for large datasets. After all data is loaded from the dataset, the grid is disconnected from the dataset. The full base class TAdvStringGrid operations on the data can now be directly executed. A disadvantage is that the grid will not operate synchronously with the dataset cursor and cannot edit the dataset. It will depend on the requirements of your applications what mode is recommended. For typical reporting scenarios where user just needs to view, sort, print, export data the grid with PageMode set to false is adequate and operates with minimum amount of code to add. For scenarios where data should be editable, where a dataset cursor is important, where a very large dataset is used, ... it is recommended to use TDBAdvGrid with PageMode set to true.
The scrollbar is only limited to three positions
This behavior is caused by the dataset. When grid.PageMode = true and DataSetType = dtNonSequenced the grid only displays a buffer of visible records, the grid has no information at all where this buffer is positioned in the database except that it is the first buffer, last buffer or not the first or last buffer. Hence, there are only 3 possible scrollbar positions.When you set grid.PageMode = false, the grid loads & shows all records and can thus show an exact scrollbar position.
After updating the ClientDataSets, data is missing in the grid and several rows are blank
Make sure that grid.PageMode = true and that grid.DataSetType = dtNonSequenced. That should improve the performance. This is also explained at page 6 of the TDBAdvGrid developers guideOther than the column properties, some other settings need to be considered. With PageMode set to true, some datasets maintain internally an order for returning the pages of displayed rows to the grid and some not. This depends on the implementation of the TDataSet component that is used to connect to the database of choice. In general, when there is a problem with scrolling in the grid, it is recommended to set the property DataSetType to dtNonSequenced.
Filtering and sorting in TDBAdvGrid
If you want to use the built-in sorting capabilities of the grid, you need to set grid.PageMode= false. This way, you can use the same capabilities to filter as for a TAdvStringGrid. Alternatively, perform the filtering on your dataset. With dataset filtering, you can leave TDBAdvGrid.PageMode = true. Please have a look at the demos ADOSort / BDESort in the TDBAdvGrid samples distribution as well as the topic on sorting in the TDBAdvGrid developers guide that explains how you can use the OnCanSort event to achieve this.Grouping in TDBAdvGrid
PageMode = false is a requirement for grouping.Changing the DB cursor
It is by design that when grid.PageMode = false, the grid will not automatically move the DB cursor when selecting rows. If you need this functionality and you have a DB key field in the grid, implement the OnSelectCell event, from this event get the DB key value via grid.Cells[col,row] and use DataSet.Locate to move the DB cursor to this selected record.Disjunct row selection in TDBAdvGrid
The built-in feature disjunct row selection requires that grid.PageMode = falseWhen grid.PageMode = true, the disjunct row selection cannot work. In this mode, only the records that are visible are displayed in the grid, no other rows are loaded in the grid. It is unfortunately not possible to keep the selection state for rows that are not loaded/visible in the grid.