UltraGrid does not reflect changes when using batching

Posted by Alex_u4a on 09-Dec-2008 10:22

I'm using a Form with an UltraGrid and a ProBindingSource as datasource. When using batching the grid does not show the added rows (empty rows are added).

There is a batching example in the GuiForDotNet directory which does work, but I don't see what the important difference is with my little test.

This is the code I added to the Form class:

DEF TEMP-TABLE ttCustomer LIKE Customer.

DEF DATASET dsCustomer FOR ttCustomer.

DEF VAR hCustomer AS HANDLE.

DEF VAR numRecs AS INT NO-UNDO.

In the constructor:

CREATE DATA-SOURCE hCustomer.

hCustomer:ADD-SOURCE-BUFFER(BUFFER Customer:handle,"custnum").

BUFFER ttCustomer:ATTACH-DATA-SOURCE(hCustomer).

BUFFER ttCustomer:BATCH-SIZE = 10.

DATASET dsCustomer:FILL().

bindingSource1:HANDLE = DATASET dsCustomer:HANDLE.

ultraGrid1:DataSource = bindingSource1.

And in the OffEnd event:

DEF VAR numTot AS INT NO-UNDO.

hCustomer:RESTART-ROWID = hCustomer:NEXT-ROWID.

BUFFER ttCustomer:ATTACH-DATA-SOURCE(hCustomer).

DATASET dsCustomer:FILL().

IF BUFFER ttCustomer:LAST-BATCH THEN

DO:

FOR EACH ttCustomer:

numTot = numTot + 1.

END.

ASSIGN args:RowsAdded = numTot - numRecs

bindingSource1:Batching = FALSE.

END.

ELSE

ASSIGN args:RowsAdded = BUFFER ttCustomer:BATCH-SIZE

numRecs = numRecs + BUFFER ttCustomer:BATCH-SIZE.

The 'batching' property of the bindingsource is set to true. Also I added the customer fields in the bindingsource designer (if I don't do this, the OffEnd event does not seem to be called).

The records do get added to the temp-table, but the are not shown in the grid. Any suggestions what I'm missing?

All Replies

Posted by Håvard Danielsen on 10-Dec-2008 13:14

You need to reopen the query when new records have been added.

The following statement after the fill in the offend event should make it behave as expected:

dataset dscustomer:top-nav-query(1):query-open().

Posted by Alex_u4a on 10-Dec-2008 14:46

Thanks, that did the trick.

This thread is closed