Can you get back the temp-table row from UltraGridRow?

Posted by jquerijero on 15-Jul-2009 16:10

Is there a way to get the bound temp-table row from a given UltraGridRow?

All Replies

Posted by Admin on 16-Jul-2009 02:18

Do you have some more input on your use case?

Basically, the BindingSource should reposition the query to the selected record - so you should be able to access the buffer fields directly. It get's a bit more complicated if you need access to a list of rows (let's say when you are allowing multiple selected rows). Here's a sample.

I would suggest that you use the selected rows cell values:

DEFINE VARIABLE oRow AS UltraGridRow NO-UNDO .

DEFINE VARIABLE i    AS INTEGER      NO-UNDO.

          

IF ultraGrid1:Selected:Rows:Count = 0 THEN DO:

    MESSAGE "No selected row"

              VIEW-AS ALERT-BOX.

    RETURN .

END.

          

DO i = 0 TO ultraGrid1:Selected:Rows:Count - 1:

         ASSIGN oRow = ultraGrid1:Selected:Rows[i] .

         

         IF NOT oRow:IsDataRow THEN DO:

             MESSAGE "No data row selected (group header etc.)"

                   VIEW-AS ALERT-BOX.

            RETURN.

        END.

              

         MESSAGE "DataRow:"   oRow:IsDataRow SKIP

                 "ListIndex:" oRow:ListIndex SKIP

              "Query Cell Values:" UNBOX(oRow:Cells["OrderNum"]:Value) UNBOX(oRow:Cells["OrderDate"]:Value) 

            VIEW-AS ALERT-BOX.

              

END.

If you need access to the actual record, use the rows ListIndex property and REPOSITION the query TO ROW (ListIndex + 1).

Posted by jquerijero on 16-Jul-2009 08:49

It allows you to impose some level of separation between the UI and the code. Using the temp-table row instead of the UltraGridRow in the code is much more simplier too.

Posted by Admin on 16-Jul-2009 08:57

jquerijero schrieb:

It allows you to impose some level of separation between the UI and the code. Using the temp-table row instead of the UltraGridRow in the code is much more simplier too.

I'm pretty sure we can argue about that with no end. I'd consider using the temp-table or a Progress buffer a constant. The Grid is just like a pretty dress that you love today but might not want to wear anymore next year. The more dependencies your code has on the actual Grid Control the harder it will become to take DevExpress or MS version of a grid next year....

We won't get rid of the ABL that soon (if ever).

Posted by Admin on 16-Jul-2009 08:58

Sorry - looks like I mis-read your post.

So in that case, go along with repositioning the Query based on the ListIndex property. Should work well.

If you need access to the actual record, use the rows ListIndex property and REPOSITION the query TO ROW (ListIndex + 1).

This thread is closed