bindingsource and ultragrid

Posted by bart.syryn on 08-Jun-2017 07:16

see next post (lay-out)

Posted by Lieven De Foor on 22-Jun-2017 06:57

If you pass the temp-table by reference, it goes out of scope at the end of the constructor, so it's unavailable in any other methods.

You can use BIND instead to keep the reference bound after the method/constructor goes out of scope.

That way you don't have to pass it by value...

All Replies

Posted by bart.syryn on 08-Jun-2017 07:20

Hi,

Probably a very stupid question, but I just can't figure it out.

Version : OE11.3

I have a:

- bindingsource

- temp-table

- infragistics grid

The bindingsource is attached to the grid.

I populate the grid with the following code:

   CREATE QUERY hQuery.

   hQuery:SET-BUFFERS(BUFFER ttdoublesdb:HANDLE).

   hQuery:QUERY-PREPARE("FOR EACH ttdoublesdb").

   hQuery:QUERY-OPEN().

   bindSrc_ttdoublesdb:HANDLE = hQuery.

How comes that the record of temp-table ttdoublesdb doesn't come available when the following events of the grid are fired:

ultraGrd_ttdoublesdb_AfterSelectChange

ultraGrd_ttdoublesdb_DoubleClickRow

What am I doing wrong here ....

Kind regards

Bart

Posted by Laura Stern on 08-Jun-2017 08:43

You're right.  It seems that the ttdoublesdb buffer should contain the record that is newly selected (AfterSelectChange) or double clicked on (DoubleClickRow).  Check the Position property of the BindingSource.  This is specifically what tracks/determines the current record in the buffer.  The Position property should be getting reset by the control (usually indirectly via internal CurrencyManager object).  Maybe that is not working as you would expect.  

Posted by bart.syryn on 08-Jun-2017 09:26

The bindingsource gives me position 0.....

Posted by Laura Stern on 08-Jun-2017 09:34

Always??  Regardless of which row we are talking about??  The position is 0-based, so 0 is a good number.  However, it should be changing as you click around on the grid.

Posted by Laura Stern on 08-Jun-2017 09:34

P.S.  You could subscribe to the BindingSource PositionChanged event just as an experiment to see what is happening to it as you do different things in the control.

Posted by bart.syryn on 08-Jun-2017 09:49

hmm, your correct, I get the exact number (zero based), sorry for that.

The position changed gets executed, but then ..... Is there something I need to do to get the ttdoublesdb record to be found .... ?

Posted by Laura Stern on 08-Jun-2017 09:53

No.  Every time Position changes, the record in the buffer should change to match it.  Are you not seeing that?  Again, you could experiment with the PositionChanged event to see.

Posted by bart.syryn on 08-Jun-2017 10:01

I think I found something, and it's logical.

It's a dialog form, and the temp-tables comes in as a parameter:

CONSTRUCTOR PUBLIC dgdoublesdb(INPUT M_type AS CHARACTER,

                              INPUT TABLE ttdoublesdb ):

So it's not available somewhere else.  I'm new in .NET, what is the best way to pass a temp-table to a (dialog)-form ?

Posted by jquerijero on 08-Jun-2017 11:46

I think I've seen this behavior before. I'm trying to remember if it was the reason we started binding to a dataset instead of query.

Can you set the bindingsource handle to the temp-table or dataset handle instead of a query handle to see if the current record goes into scope?

Posted by Laura Stern on 08-Jun-2017 11:50

You cannot bind to a temp-table.  And you should NOT bind to a DataSet unless you want to see hierarchical data.  If you are just binding to the data from one table, you should bind to a query just like he was doing..

Besides that, I don't understand the question.  We are talking about ABL here.  I.e., Your class dbdoublesdb is an ABL constructor.  You pass temp-tables here the same way you pass them everywhere else.   How is this related to your original problem?

Posted by jquerijero on 08-Jun-2017 14:00

Anyway, check your grid settings;

- DoubleClickRow event should fire unless you have an editor container embedded in the cell.

- AfterSelectChange event will not fire (so it will not put a record in scope) for some of the CellClickAction values. Try setting it to CellSelect.

Posted by bart.syryn on 09-Jun-2017 04:05

I have been playing around with this, and I was passing the temp-table 'BY-REFERENCE'.

Not passing the temp-table BY-REFERENCE solves the problem.

When I pass the TT BY-REFERENCE, the records are available in the CONSTRUCTOR, but not in any other method.

So passing a temp-table to a Form, can't be passed BY-REFERENCE. I found that strange, but there must be a reason for that ....

Posted by jquerijero on 16-Jun-2017 17:22

Thanks for sharing.

Posted by Lieven De Foor on 22-Jun-2017 06:57

If you pass the temp-table by reference, it goes out of scope at the end of the constructor, so it's unavailable in any other methods.

You can use BIND instead to keep the reference bound after the method/constructor goes out of scope.

That way you don't have to pass it by value...

Posted by bart.syryn on 22-Jun-2017 11:09

Adding BIND to the input table, solved the problem.

Posted by jquerijero on 22-Jun-2017 12:10

That's interesting. Do you know why it is not affecting the UltraGrid that references the out-of-scope temp-table?

Posted by Mike Fechner on 22-Jun-2017 12:15

The Grid is not receiving any notification when the temp-table goes out of scope. This requires the query to be reopened and/or the Binding Source :RefreshAll() .

I would however expect, that the Grid can be wiped out by hovering with the mouse over cells.

This thread is closed