Subject Grids and Bookmarks (corrected)
Author staff@belding
Hello All

(my first post on this was wrong)

I have an IB_Grid with an IB_Query for its datasource. I am using the
OrderingItems and OrderingLinks of the query object to allow users to sort
the grid's columns. This is all OK.

If a grid row is selected and a reorder is done the selected row changes. I
would like to have the selected row persist through a column reorder.
Perhaps using a bookmark is best here. Now the question is which query or
grid event
is best to use first capture the existing selected row and secondly to tell
the query to return to a saved bookmark. Perhaps the
event I want is the Queries OnOrderingChange?

Looking at this event, it is called twice after a title button is pressed.
The first call is done when the Query.Active is false. (This sentence is wrong ....But the
Query.Bookmark points to the existing selected row) On this first call I can trap the bookmark for the selected row which has bee set in the OnDataChange event for the Query. The second call has
Query.Active true and can be used to set the Query.bookmark.

Here is code to keep the selected row through a reorder..

procedure Form1.dataSourceForGridQueryDataChange(.....);
the Bookmark := qrGridQuery.Bookmark;

procedure Form1.qrGridQueryOrderingChange(IB_Dataset : TIB_Dataset);
begin {called twice on each ordering change, once acitve=False, once
{my conditions for entry}
with qrGridQuery do
if not Active then
desiredBookmark := theBookmark;
end:{not Active}
bookmark := desiredBookmark;
end;{with ..}

The volume of data in the grid is small. With D5 and IBO 3.6Ce Test3 this

Is there a better way to achieve my goal?
Am I inviting problems assuming the OnOrderingChange event always will work
this way?

I tried using event Grid event OnTitleClick to capture the bookmark of the
prior select row but when this event is called the Query.Bookmark of the
selected row is the null string.

Regards and thanks


[Non-text portions of this message have been removed]