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:
The only example of collapsing rows is in HierarchicalGrid which is totally different.
How can I accomplish this on a TreeGrid?
Thank you
Thank you, that did work.
But it certainly isn't clear that this extra line of code is needed :
var row = $(rows[i]);
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 ElliottAssociate Software DeveloperInfragistics, Inc.www.infragistics.com