Delay selecting the new row in UltraGrid after query Reposit

Posted by justinfowler on 18-Mar-2014 12:55

I have an UltraGrid with 15 rows. You can see about 5 rows on the screen.

It is attached to a bindingsource, which is attached to a query on a temp-table. By default the first row (record) is selected using a GET-FIRST().

This is how I initialize the binding source:

/* populate the temp-table, then... */

DATASET dsRecords:HANDLE:TOP-NAV-QUERY():QUERY-PREPARE("preselect each ttRecords no-lock").
DATASET dsRecords:HANDLE:TOP-NAV-QUERY():QUERY-OPEN().
DATASET dsRecords:HANDLE:TOP-NAV-QUERY():GET-FIRST().
bindingsource:HANDLE = DATASET dsRecords:HANDLE:TOP-NAV-QUERY.

The user types a number into a box and the leave event fires a reload method that repositions the query based on the entered data. This method also does a lot of other work after.

Here is the code, assume no error checking:

.
.
ultragrid:AfterRowActivate:Unsubscribe(THIS-OBJECT:ultragrid_AfterRowActivate).

FIND FIRST ttRecords NO-LOCK WHERE ttRecords.id = vUsersValue NO-ERROR.
IF AVAIL ttRecords THEN
DATASET dsRecords:HANDLE:TOP-NAV-QUERY:REPOSITION-TO-ROWID(ROWID(ttRecords)).

ultragrid:AfterRowActivate:Subscribe(THIS-OBJECT:ultragrid_AfterRowActivate).

/* now do another half second of processing, loading usercontrols, etc etc */

When the record I am repositioning to is visible on screen, no issue, the record is selected instantly.

When the record is NOT visible on screen, there is about a 1 second delay before the ultragrid repositions itself and displays the selected record. In that time, the rest of the code has carried on and loads in normal time.

I can type the value, hit tab, wait .5 seconds and the entire screen is loaded, then wait another .5 seconds and the ultragrid will be updated.

Also, you will see I am trying to stop the afterrowactivate from firing on this reposition command. It always fires.

How can I minimize the delay?

How I can make progress wait for the update to the ultragrid before executing the subscribe?

Thank you in advance!!

Posted by justinfowler on 20-Mar-2014 08:04

Here's a solution that works with sorting:

ultragrid:Rows:GetRowWithListIndex(bindingsource:Position):Activate() NO-ERROR.

All Replies

Posted by justinfowler on 18-Mar-2014 13:11

Found this in my PEG archive:

grid:Rows[<binding>:Position]:Activate ()

Fixes both of my issues.

Why do I need this line? What is causing the delay?

Posted by justinfowler on 20-Mar-2014 08:04

Here's a solution that works with sorting:

ultragrid:Rows:GetRowWithListIndex(bindingsource:Position):Activate() NO-ERROR.

This thread is closed