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
45
Expand / Collapse all rows
posted

I'm trying to write code for a simple buttons 'Expand All' and 'Collapse All' and cannot get it to work.

I thought I could get 'allRows' and then call 'collapseRow' on each one, but this doesn't work :

var rows = $(grid).igTreeGrid("allRows");

for ( i=0; i<rows.length; i++ ) {

     $(grid).igTreeGrid("collapseRow",rows[i]);

}

The 'row' returned from allRows is NOT accepted by 'collapseRow', even though the API Doc says the parameter is

"jQuery table row object, raw DOM row object or a row id."

I tried this with failure:

  • $(grid).igTreeGrid("rows"); ==> returns the exact same array of rows
  • $(grid).igTreeGrid("collapseRow",rows[i].element); ==> hangs the grid
  • var id = row.id;  ==> use id value like the returned row from 'selectedRow' method, but it doesn't exist

The only example of collapsing rows is in HierarchicalGrid which is totally different.

How can I accomplish this on a TreeGrid?

Thank you

  • 2525
    posted

    Hello Rob,

    I made a slight modification to the code you provided to make it work. I am utilizing the jQuery selector to obtain the dom element and passing that value to the collapseRow method when iterating over the rows to achieve the desired behavior.

    This is the resulting code:

    var rows = $("#treegrid").igTreeGrid("allRows");

    for(var i = 0; i < rows.length; i++){
                       
         var row = $(rows[i]);
         $("#treegrid").igTreeGrid("collapseRow", row);
                       
    }

    I am also attaching a sample that I used to test this behavior and achieves the desired behavior.

    I will be looking into this a bit deeper as the initial code that you provided I would expect to work.

    Sincerely,
    Sam Elliott
    Associate Software Developer
    Infragistics, Inc.
    www.infragistics.com

    index.zip