1

I am using DevExpress TcxGrid in Delphi 2009 application (that's right, 100 years old IDE) and I have the following call stack (from madExcept):

SplendidSoft.exe SplendidDMU              1051  +3 TSplendidDM.ImportedDataCSAfterScroll
SplendidSoft.exe DB                                    TDataSet.DoAfterScroll
SplendidSoft.exe DB                                    TDataSet.First
SplendidSoft.exe cxDBData                     2056 +21 TcxDBDataProvider.First
SplendidSoft.exe cxCustomData                 7638 +17 LoadData
SplendidSoft.exe cxCustomData                 7689  +6 TcxCustomDataController.LoadStorage
SplendidSoft.exe cxDBData                     4943  +3 TcxDBDataController.LoadStorage
SplendidSoft.exe cxCustomData                 7893 +20 TcxCustomDataController.UpdateStorage
SplendidSoft.exe cxCustomData                 7991 +16 TcxCustomDataController.DataChanged
SplendidSoft.exe cxCustomData                11107  +2 TcxCustomDataProvider.DataChanged
SplendidSoft.exe cxDBData                     1459 +53 TcxDBDataLink.DataSetChanged
SplendidSoft.exe DB                                    TDataLink.DataEvent
SplendidSoft.exe cxDBData                     1399  +1 TcxDBDataLink.DataEvent
SplendidSoft.exe DB                                    TDataSource.NotifyLinkTypes
SplendidSoft.exe DB                                    TDataSource.NotifyDataLinks
SplendidSoft.exe DB                                    TDataSource.DataEvent
SplendidSoft.exe DB                                    TDataSet.DataEvent
SplendidSoft.exe DBClient                              TCustomClientDataSet.DataEvent
SplendidSoft.exe DB                                    TDataSet.Resync
SplendidSoft.exe DB                                    TDataSet.Post
SplendidSoft.exe DBClient                              TCustomClientDataSet.Post
SplendidSoft.exe DB                                    TDataSet.CheckBrowseMode
SplendidSoft.exe SplendidFormU   295  +4           TSplendidForm.cxButton2Click

cxButton2Click simply calls Post on the underlying dataset and one can see that this simple post initiated the chain of events that leads to the full reload of data and hence - multiple AfterScroll events.

Why it is so? Post just saves all the data that are already in the current record/cells of the grid, so, there is no need to reload even the single record. But TcxDBDataProvider reloads entire dataset, why it is so and how to prevent it? Is this the standard behaviour of the TcxGrid? And why it is so strange?

TomR
  • 2,696
  • 6
  • 34
  • 87
  • What do Devex Support say about this? They should be the first people to ask. – MartynA Aug 26 '19 at 14:07
  • The cxGrid is fairly complex - if you are going to be creating or maintaining code using it then taking some time learning the component will pay off vs trying to figure things out as you work on parts of an application / code base. They also have really good support and newer versions have had performance improvements so getting a current subscription might help as well. – Brian Aug 26 '19 at 14:21
  • 2
    `SmartRefresh` is what you are looking for. – BrakNicku Aug 26 '19 at 14:24

1 Answers1

3

If some conditions are met you can use SmartRefresh.

   cxGrid1DBTableView1.DataController.DataModeController.SmartRefresh := true;

Make sure you read the help as there are some restrictions, for example:

Note: If a data controller is in Smart Refresh mode and dataset records are managed via the data controller, the records are automatically updated. If dataset records are modified via the dataset's methods or by external controls, you need to manually call the UpdateItems method to reload all records with new data.

This means you need to use DataController.* instead of a TDataSet.* methods.

// Use DataController methods   
cxGrid1DBTableView1.DataController.Post();
// Instead of TDataSet methods
FDTable1.Post;
Brian
  • 6,717
  • 2
  • 23
  • 31