Page 1 of 1

Stop auto scroll with DBGrid

Posted: 28.09.2014, 21:11
by IbeDBob
Hi All,

I have an irritating issue with Delphi, SQLite, Zeos and a DBGrid.
If I have a database of say 300 items and the DBGrid had that has 7 visible rows.
I have an OnCellClick event that toggles a Boolean.

tblShop.Edit;
tblShop.FieldByName('Active').AsBoolean:=not(tblShop.FieldByName('Active').AsBoolean);
tblShop.Post;

If the row I want to toggle is Item 135 which is at Row 6 and I click, the boolean is toggled, but then the table scrolls so that Item 135 moves to Row 4.

This is crazy stuff as it leaves the user with the cursor where item 135 used to be and now over item 137. With 7 rows in this example, not too big of a deal, but with 20 visible rows, it is insanely annoying as it does it above and below the center row always having focus.

Is there some way to turn of this auto-vertical-centering?
e.g. I start with this...

Row 1, item 130
Row 2, item 131
Row 3, item 132
Row 4, item 133
Row 5, item 134
Row 6, item 135 <-- if I click here
Row 7, Item 136

this is what I get...

Row 1, item 132
Row 2, item 133
Row 3, item 134
Row 4, item 135 <-- Row I just edited gets moved up to here
Row 5, item 136
Row 6, item 137 <-- cursor still here
Row 7, Item 138

The reverse happens if I click above the center line Row, the damned thing moves the edited line down to the center row.

How can I disable this crazy behavior?

I have tried with a different set of data aware DB components and it does not happen. It is something the Zeos dbgrid component is doing.

Thanks

Re: Stop auto scroll with DBGrid

Posted: 28.09.2014, 21:19
by EgonHugeist
add doDontSortOnPost to your TZDataSet-descendant Options:

TZDataSet.Options := [YourOptions + doDontSortOnPost]; -> also visible in property editor

Re: Stop auto scroll with DBGrid

Posted: 28.09.2014, 23:44
by IbeDBob
Michael, thanks for the quick reply, but this is what I did and it doesn't help.
In unit ZAbstractRODataset;
{** Options for dataset. }
TZDatasetOption = (doOemTranslate, doCalcDefaults, doAlwaysDetailResync, doSmartOpen, doDontSortOnPost);

But the doDontSortOnPost does not show up in the property editor even after recompiling the component package.

Might be a bit out of my depth here. :)

Could you be a little more specific please?

Re: Stop auto scroll with DBGrid

Posted: 29.09.2014, 00:59
by miab3
@IbeDBob,

Screen for ZEOSDBO-7.1.3a-patches r3268:
http://svn.code.sf.net/p/zeoslib/code-0 ... 1-patches/
zeos7.1p_r3268.png
http://zeoslib.sourceforge.net/viewtopi ... 514#p31514

Michal