Cursor jumps in detail DS on master refresh (w/fix)
Posted: 01.08.2014, 15:38
Under some conditions cursor for detail DS may jump on master refresh.
I catched it with the following scheme:
Master: TZTable, Detail: TZQuery, DetailGrid: TDBGridEh (a grid from EhLib, version 3.6) connected to Detail.
Now if we execute Master.Refresh, the cursor for Detail jumps downward. This happens only with TDBGridEh attached while stock Delphi 7 grid is OK. But probably other custom grids produce this issue as well. I presume so because I see many quite odd manipulations with TZAbstractRODataset.CurrentRow property in Zeos while this property is used to move the cursor on refresh.
Luckily I managed to find an extremely trivial solution:
method
line
add before the line
So before refreshing we force CurrentRow to correspond the cursor.
Talking generally, I'd advice to redesign usage of CurrentRow or at least correct it with UpdateCursorPos every time it is used as "index of a record the cursor points at".
I catched it with the following scheme:
Master: TZTable, Detail: TZQuery, DetailGrid: TDBGridEh (a grid from EhLib, version 3.6) connected to Detail.
Now if we execute Master.Refresh, the cursor for Detail jumps downward. This happens only with TDBGridEh attached while stock Delphi 7 grid is OK. But probably other custom grids produce this issue as well. I presume so because I see many quite odd manipulations with TZAbstractRODataset.CurrentRow property in Zeos while this property is used to move the cursor on refresh.
Luckily I managed to find an extremely trivial solution:
method
Code: Select all
TZAbstractRODataset.RereadRows
Code: Select all
if (CurrentRow > 0) and (CurrentRow <= CurrentRows.Count) and
Code: Select all
UpdateCursorPos;
So before refreshing we force CurrentRow to correspond the cursor.
Talking generally, I'd advice to redesign usage of CurrentRow or at least correct it with UpdateCursorPos every time it is used as "index of a record the cursor points at".