Consultor Eletrônico



Kbase P140977: How to navigate the UltraGrid row hierarchy using ABL
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   2/23/2011
Status: Verified

GOAL:

How to navigate the UltraGrid row hierarchy using ABL

GOAL:

How to traverse all the rows in an UltraGrid band using ABL (4GL)

GOAL:

How to loop through the child rows of an UltraGrid parent row with ABL (4GL)

GOAL:

How to walk through the descendants of a parent row in an Infragistics UltraGrid using ABL (4GL)

FACT(s) (Environment):

Windows
OpenEdge 10.2x

FIX:

The following example code shows one method of traversing the UltraGrid row hierarchy using ABL. The example assumes an Ultragrid named UltraGrid1 with an arbitrary number of columns. It displays selected information from all rows of UltraGrid1, using a recursively called helper method. The helper method could also be called to process all descendants of a single row, such as the active row.

DEFINE VARIABLE GridRowColl AS Infragistics.Win.UltraWinGrid.RowsCollection NO-UNDO.
DEFINE VARIABLE GridRow AS Infragistics.Win.UltraWinGrid.UltraGridRow NO-UNDO.
DEFINE VARIABLE iNumTopRows AS INTEGER NO-UNDO.
DEFINE VARIABLE ii AS INTEGER NO-UNDO.
GridRowColl = ultraGrid1:Rows.
iNumTopRows = GridRowColl:Count.
ii = 0.

/* Loop through all top-level rows and access the descendants of each one */
DO WHILE ii < iNumTopRows:
GridRow = GridRowColl[ii].
traverse(GridRow).
ii = ii + 1.
END.
/* To traverse only the descendants of the active row, replace the above code with:
GridRow = ultraGrid1:ActiveRow.
traverse(GridRow).

*/

/* Helper method called recursively to display certain cell properties of all rows descended from a
single top-level row. */
METHOD PRIVATE VOID traverse(INPUT ParentRow AS Infragistics.Win.UltraWinGrid.UltraGridRow):
DEFINE VARIABLE ChildBandsColl AS Infragistics.Win.UltraWinGrid.ChildBandsCollection NO-UNDO.
DEFINE VARIABLE ChildBand AS Infragistics.Win.UltraWinGrid.UltraGridChildBand NO-UNDO.
DEFINE VARIABLE ChildRowsColl AS Infragistics.Win.UltraWinGrid.RowsCollection NO-UNDO.
DEFINE VARIABLE ChildRow AS Infragistics.Win.UltraWinGrid.UltraGridRow NO-UNDO.
DEFINE VARIABLE CurrentCell AS Infragistics.Win.UltraWinGrid.UltraGridCell NO-UNDO.
DEFINE VARIABLE iNumBands AS INTEGER NO-UNDO.
DEFINE VARIABLE iNumRows AS INTEGER NO-UNDO.
DEFINE VARIABLE iNumCols AS INTEGER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE j AS INTEGER NO-UNDO.

/* Note that there is no FOR EACH in this code. Examples in the Infragistics documentation use a
C# foreach, but the ABL FOR EACH can only be used to loop through database records. */


i = 0.
/* Call this method recursively if this row has any children */
IF ParentRow:HasChild() THEN DO:
ChildBandsColl = ParentRow:ChildBands.
iNumBands = ParentRow:ChildBands:Count.
DO WHILE i < iNumBands:
ChildBand = ChildBandsColl[i].
ChildRowsColl = ChildBand:Rows.
iNumRows = ChildRowsColl:Count.

j = 0.
DO WHILE j < iNumRows:
ChildRow = ChildRowsColl[j].
traverse(ChildRow).
j = j + 1.
END.


i = i + 1.
END.

END.
/* This row has no children: display the Text and Value properties for each cell in the row */

ELSE DO:
iNumCols = ParentRow:Cells:Count.
DO WHILE i < iNumCols:
CurrentCell = ParentRow:Cells[i].
/* The Text property of an UltraGridCell is analagous to the ABL SCREEN-VALUE. The Value property
&n.bsp; is the cell's internal value. */
MESSAGE "You see " CurrentCell:Text SKIP
"but my real value is " CurrentCell:Value
VIEW-AS ALERT-BOX.

i = i + 1.
END.

END.


END METHOD. .