View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0027232||Lazarus||Database Components||public||2015-01-02 11:01||2015-04-22 16:14|
|Reporter||Luca Olivetti||Assigned To||Jesus Reyes|
|Product Version||1.2.6||Product Build|
|Target Version||1.4||Fixed in Version||1.5 (SVN)|
|Summary||0027232: TDBGrid doesn't fire OnSelectEditor if scrolling past visible extent|
|Description||When scrolling past the visible rows (either using the up/down arrow, a db navigator or the scrollbar of the grid) the OnSelectEditor event doesn't fire even if the record has changed.|
If an editor was previously selected, now it would show the value of the previous record and, worse, it could lead to an unintended modification of the new record.
|Steps To Reproduce||Compile and run the attached project. It should load enough test data to fill more than the visible rows.|
Click on any cell and see that in the memo is registered the firing of the OnSelectEditor event.
Click on the first cell of the last visible row and again see that OnSelectEditor fires.
Now use the keyboard down arrow to select the next row. OnSelectEditor isn't fired this time.
|Additional Information||Tested both under windows and linux.|
|Tags||No tags attached.|
|Fixed in Revision||47911|
bug_selecteditor.zip (3,154 bytes)
SelectEditor is only triggered if the Row changes (in Grids.pas, TCustomGrid.SetRow exits if it's the same row, so it doesn't call MoveExtend which actually calls SelectEditor), *but* since we're scrolling the grid, the row number doesn't change event if the record has changed.
I don't think it's enough to call SelectEditor in TCustomDBGrid.OnDataSetScrolled (in case Distance<>0) because MoveExtend also checks for editability and the AlwaysShowEditor option, i.e., this is what MoveExtend does
if (FEditor<>nil) and EditorAlwaysShown then begin
// if editor visibility was changed on BeforeMoveSelection or MoveSelection
// make sure editor will be updated.
// TODO: cell coords of last time editor was visible
// could help here too, if they are not the same as the
// current cell, editor should be hidden first too.
if FEditor.Visible then
but neither FEditor nor EditorAlwaysShown are visible to the TDbGrid.
The former could be substituted for its accessor InplaceEditor and EditorAlwaysShown by (dgAlwaysShowEditor in Options) (though it is incomplete).
Or maybe the above could be put in a protected method of the Grid than can be called by the DbGrid.
What do you think?
Actually the above is not necessary, because TCustomDBGrid.OnDataSetScrolled already hides and (if necessary) shows the editor.
Just adding a call to SelectEditor in the
if Distance<>0 then begin
part should be enough (I put it after the Invalidate).
||Thanks, I modified the patch to avoid that eventually OnSelectEditor would be called twice|
||Thank you. Will it be merged in the upcoming 1.4?|
||I'm sorry, it's now queued.|
||Lazarus 1.4 has been released today without this fix|
||what you mean?, I can see the patch in the release, the one before the tagging: http://svn.freepascal.org/cgi-bin/viewvc.cgi/tags/lazarus_1_4/lcl/dbgrids.pas?diff_format=l&root=lazarus&view=log|
||Sorry for the noise, I was misled by the merge to my local version from the subversion repository.|
|2015-01-02 11:01||Luca Olivetti||New Issue|
|2015-01-02 11:01||Luca Olivetti||File Added: bug_selecteditor.zip|
|2015-01-03 00:44||Jesus Reyes||Assigned To||=> Jesus Reyes|
|2015-01-03 00:44||Jesus Reyes||Status||new => assigned|
|2015-01-28 13:14||Luca Olivetti||Note Added: 0080636|
|2015-01-28 17:03||Luca Olivetti||Note Added: 0080642|
|2015-02-20 04:23||Jesus Reyes||Fixed in Revision||=> 47911|
|2015-02-20 04:23||Jesus Reyes||LazTarget||=> 1.4|
|2015-02-20 04:23||Jesus Reyes||Note Added: 0081273|
|2015-02-20 04:23||Jesus Reyes||Status||assigned => resolved|
|2015-02-20 04:23||Jesus Reyes||Fixed in Version||=> 1.5 (SVN)|
|2015-02-20 04:23||Jesus Reyes||Resolution||open => fixed|
|2015-02-20 04:23||Jesus Reyes||Target Version||=> 1.4|
|2015-02-20 17:46||Luca Olivetti||Note Added: 0081286|
|2015-03-03 02:15||Jesus Reyes||Note Added: 0081583|
|2015-04-22 13:05||Luca Olivetti||Note Added: 0083106|
|2015-04-22 15:25||Jesus Reyes||Note Added: 0083111|
|2015-04-22 16:14||Luca Olivetti||Note Added: 0083113|
|2015-04-22 16:14||Luca Olivetti||Status||resolved => closed|