I have searched on this and found ExpandAll() and CollapseAll() but these are not working in response to server-side button click. I want to have buttons - Expand All and Collapse All that will perform this function. If this can be done in javascript client-side that would be preferred.
This is not working either:
function collapseAll() {
var grid = $find("hgrid");
var groupRow = grid.get_gridView().get_groupRows().get_row(0);
var row;
for (var i = 0; i < groupRow.get_rows().length; i++) {
row = groupRow.get_rows()[i];
row.groupRow.collapseAll();
}
Hello,
Thank you for contacting us!
Below you will find a sample which is showing exactly this, how to expand/collapse all WHDG rows with one click.
Code snippet:
// function ToggleRows(expandOrCollapse) { var grid = $find('WebHierarchicalDataGrid1');
var rowsLength = grid.get_gridView().get_rows().get_length();
for (var i = 0; i grid.get_gridView().get_rows().get_row(i).set_expanded(expandOrCollapse); }
for (var i = 0; i grid.get_gridView().get_groupRows().get_row(i).set_expanded(expandOrCollapse); } } // ]]>
This is working perfectly! Thanks!
How can we use same code on code behind i want to expand level by level.
For example I have 4 levels of WHDG => and I have 4 button => i want expand all child for 1st level on 1st button then same as second.. Can we achive this ???
Please send sample with VB.net
Hi,
I tried your sample and its works fine in a grid with 2 levels, with more than 2 levels it doestn work.
I am glad that I've managed to help you!
Thank you for using our products.