Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
120
Navigation through multiple bands in a grid.
posted

Hi

I am working on Testadvantage 2.0. Application is having a Ultragrid with multiple bands. using the HasChild identified the whetehr the specific row has child rows. Not able to set the focus on the child rowsin the band2.

 

Could you please let me know/ provide sample code how to iterate through the child rows in each band.

 

 

  • 7695
    Suggested Answer
    Offline posted

    Hi,

      Depending on the amount of bands depends on the complexity needed for the solution. Do you just have two bands, the root band, which is Band[0], and a child band, Band[1]. Are there more than that? If there are more, is it a simple hierarchy of Root, Child, GrandChild, Great GrandChild,... or are there sibling bands? IE Root, Child1, Child2, GrandChild1(Child of Child1), GrandChild2(Child of Child1), ... the grid has many possible data possibilities, and while it may be possible to create a means to work with all of them, the complexity would likely be far greater than you need.

       That being said, I will start off with the basic, and give you the general idea on how to build from there. For starters, most of the Grid actions use three basic parameters. RowPathArg, ColumnArg, and ColumnPathArg.

      The RowPathArg is typically the most complex, in most cases you will likely just use a simple numeric, for rows on the root band. It's when you start dealing in hierarchical data that it gets trickier to have all the possibilities be delineable by one parameter.  The parameters parsing structure looks like this

    "iRowIndex0;[[iChildBandIndex1,]iRowIndex1][;[[iChildBandIndexN,]iRowIndexN];]..."

    Seems rather complex but to simplify it by the following statements :
        Each generation level requires a iRowIndex
        Each generation level can have a sibling band specified, if not ChildBand 0 is assumed
        Each generation level, if an iChildBandIndex is needed, is listed first delimited from its row by a comma
        Each generation level is delimited by a semi-colon
        Each iIndex is for a zero based collection, where 0 is the first item

    For simple rows you can use a numeric string such as "3" or simply the integer 3.

    For simple hierarchical rows you need to use semi-colon delimited string "1;3" or "0;3;4" etc

    For complex hierarchical rows with sibling bands "3;1,3"

     

    ColumnArg is much simpler, its the zero based index or the ColumnKey.

    ColumnPathArg, which is mostly ever used when dealing with a column by itself without a row, is a semi-colon delimited string of iBandIndex and sColumnKey or iColumnIndex. So something like "0;Name" or "1;2"

     

        That all being said, from how I interpret what you are asking is that you have two band, the root, Band[0] with one child band Band[1], and you want to select each row of the child band.  That can be done as follows:

    SET grid = SwfWindow("Form1").SwfTable("ultraGrid1")

    grid.ActivateRow "0"
    iRowCount = grid.RowCount

    FOR iRow = 0 TO iRowCount - 1
        iChildBandCount = grid.GetNAProperty("Rows["+CSTR(iRow)+"].ChildBands.Count")

        IF iChildBandCount > 0 THEN
            grid.ExpandRow CSTR(iRow)

            iChildRowCount = grid.GetNAProperty("Rows["+CSTR(iRow)+"].ChildBands[0].Rows.Count")

            IF iChildRowCount > 0 THEN
                FOR iChildRow = 0 TO iChildRowCount - 1
                    rowPathArg = CSTR(iRow) +";" +CSTR(iChildRow)
                    grid.SelectRow rowPathArg
                Next
               
            END IF   
        END IF
    NEXT

     

    I hope that answers your question,