Unable to access cell values from InitializeRow

Posted by saquib on 03-Jan-2013 09:24

Hi,

I have an Ultragrid and a binding source bound to the grid.

The binding source is bound to a query and the data is displayed in the grid correctly when I perform a search:

METHOD PUBLIC VOID PopulateDataGrid( TABLE ttAllocation ):

   
    bindingSource1:HANDLE = ?.

   
    OPEN QUERY qu_Query PRESELECT EACH ttAllocation.  
   
    ASSIGN
      bindingSource1:AllowEdit    = FALSE
      bindingSource1:HANDLE    = QUERY qu_Query:HANDLE.
     
END METHOD.

My problem is when I try to test cell values in the Grid's InitializeRow event:

/*------------------------------------------------------------------------------
    Purpose:                                     
    Notes:                                     
------------------------------------------------------------------------------*/
@VisualDesigner.
METHOD PRIVATE VOID GridSpecialOffers_InitializeRow( INPUT sender AS System.Object, INPUT e AS Infragistics.Win.UltraWinGrid.InitializeRowEventArgs ):

  SetUpGridRowColours(INPUT e ).

END METHOD.

In the method "SetUpGridRowColours" this code errors with the the linked chain attributes error :

    /* set up the availability colours */
    IF  e:Row:Cells["field-name"]:Value:ToString() = "":U THEN

       etc...

The errors:

1.

---------------------------
Error (Press HELP to view stack trace)
---------------------------
Lead attributes in a chained-attribute expression (a:b:c) must be type HANDLE or a user-defined type and valid (not UNKNOWN). (10068)

2.

---------------------------
Error (Press HELP to view stack trace)
---------------------------
System.ArgumentException: Key not found

I found this as well from the stack trace:

.NET StackTrace:
-->   at Infragistics.Shared.KeyedSubObjectsCollectionBase.GetItem(String key)
   at Infragistics.Win.UltraWinGrid.ColumnsCollection.get_Item(String key)
   at Infragistics.Win.UltraWinGrid.CellsCollection.GetItem(String key)
   at Infragistics.Win.UltraWinGrid.CellsCollection.get_Item(String key)

Anyone have any ideas?

Many Thanks,

Saquib.

All Replies

Posted by dlauzon on 03-Jan-2013 12:14

What part of the expression e:Row:Cells["field-name"]:Value:ToString() is invalid?

Test using:

MESSAGE
  SKIP VALID-OBJECT(e) '
  SKIP VALID-OBJECT(e:Row) '

/*and so on*/
  VIEW-AS ALERT-BOX.

(note that the messages you have strongly suggest that "field-name" is not a valid cell/field name for the data bound to GridSpecialOffers, depending on how the BindingSource is set, the name might include the table name?)

If the cell is not found, you can always see what is in the Cells object using something like this:

DEFINE VARIABLE ObjectToDisplay AS CLASS System.Object NO-UNDO.
ObjectToDisplay = e:Row:Cells.
WAIT-FOR (NEW Infragistics.Shared.UltraPropertyPageDialog(ObjectToDisplay)):ShowDialog().

If you want the original value, you can also use UNBOX(e:Row:Cells["field-name"]:Value)

instead of using ToString()

The other thing to check is that you might be on a non-data row (e.g. group-by rows, filter rows, template add-rows, summary rows, etc.), you can use "IF e:Row:IsDataRow"

Btw, once you're sure it's a DataRow, it's not impossible that you can check the value straight in ttAllocation.field-name or bindingSource1:InputValue:Item["field-name"] (I'm not sure if the sync is already done at that point).

Posted by saquib on 04-Jan-2013 09:22

Many thanks for your reply. It has given me a few new ideas to try and I'm sure one of them will solve my problem!

This thread is closed