Stop auto scroll with DBGrid

The official tester's forum for ZeosLib 7.1. Ask for help, post proposals or solutions.
Post Reply
IbeDBob
Junior Boarder
Junior Boarder
Posts: 47
Joined: 27.05.2010, 21:04

Stop auto scroll with DBGrid

Post 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
Thanks

Dyslexic Bob
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Stop auto scroll with DBGrid

Post by EgonHugeist »

add doDontSortOnPost to your TZDataSet-descendant Options:

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

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
IbeDBob
Junior Boarder
Junior Boarder
Posts: 47
Joined: 27.05.2010, 21:04

Re: Stop auto scroll with DBGrid

Post 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?
Thanks

Dyslexic Bob
miab3
Zeos Test Team
Zeos Test Team
Posts: 1310
Joined: 11.05.2012, 12:32
Location: Poland

Re: Stop auto scroll with DBGrid

Post 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
You do not have the required permissions to view the files attached to this post.
Post Reply