Skip to content

Infragistics Community Forum / Web / Ignite UI for jQuery / Expand / Collapse all rows

Expand / Collapse all rows

New Discussion
Rob Smith
Rob Smith asked on Feb 20, 2016 9:39 PM

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

Sign In to post a reply

Replies

  • 0
    Sam Elliott
    Sam Elliott answered on Feb 19, 2016 9:28 PM

    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.
    http://www.infragistics.com

    • 0
      Rob Smith
      Rob Smith answered on Feb 20, 2016 9:39 PM

      Thank you, that did work.

      But it certainly isn't clear that this extra line of code is needed :

      var row = $(rows[i]);

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Rob Smith
Favorites
0
Replies
2
Created On
Feb 20, 2016
Last Post
10 years ago

Suggested Discussions

Tags

Created by

Created on

Feb 20, 2016 9:39 PM

Last activity on

Feb 20, 2016 9:39 PM