Is there a way to save the TDataset.Edit call while the controls are disconnected from having to update the layout when the controls are turned on?

It's a bit tied up, so carry me.

TDataset.Edit calls SetState(dsEdit); that calls the DataEvent(deUpdateState, 0);

TDataSet.DataEvent when called with the deUpdateState parameter, if you have disabled controls in your dataset, it sets a flag that will dispatch the deLayoutChange event when the controls are turned back on, which, according to the documentation, says a bit vaguely that β€œThe data location in data driven. "

When a control is re-enabled, it is a data-bound grid, this can lead to very expensive flushes, causing the whole grid to be redistributed. In a large dataset with a large number of rows and columns, this can take several seconds, even if you did not do anything while the controls were disabled, which affects the layout of the grid.

Is there any way to prevent this? SetState not virtual. DataEvent is virtual, but the FEnableEvent field that it uses for installation is not available from derived classes. There seems to be no way around this without rude hackers. (RTTI surgery, overlay classes, etc.) Does anyone know how best to do this?

+4
source share
2 answers

Based on your comment that your dataset is connected to the DevExpress grid, I would start looking there. Wrap your code that does the editing with cxgrid.BeginUpdate and cxgrid.EndUpdate and a try / finally block.

 MycxGrid.BeginUpdate; try {Do some data editing} finally MycxGrid.EndUpdate; end; 

This in itself can solve your problem. If this is not the case, look at the DevExpress help files TcxDBDataModeController.SmartRefresh and TcxDBDataModeController.SyncMode.

Without seeing my code, I only guess. But I had very similar performance issues before I discovered the BeginUpdate / EndUpdate combination.

0
source

I do not know about TcxGrid, but perhaps you could try to solve this on the control side and override TcxGrid DataLink.LayoutChanged or another method from the grid itself.

Like the TDBGrid analogy:

  • TCustomDBGrid.CreateDataLink is dynamic and can be overridden, so you can attach your own derived TGridDataLink to a TDBGrid descendant.
  • TGridDataLink.LayoutChanged is virtual and can be overridden, this is option 1.
  • TGridDataLink.LayoutChanged calls FGrid.LayoutChanged .
  • TCustomDBGrid.LayoutChanged also virtual, which makes it option 2.
0
source

All Articles