Hi,
I want to expand all the rows in my grid, I have this function that works fine with 2 levels grid, but now, I have a 3 levels grid, and it doesnt work , could you help me to figure out a solution ?
function ExpandAllRowsGrouped(Webgrid) { var grid = $find(Webgrid); var rows = grid.get_gridView().get_groupRows() var oRow for (i = 0; i < rows.get_length() ; i++) { oRow = rows.get_row(i); oRow.set_expanded(true); } }
thanks.
Hello Hugo,
Could you provide me with a few more details of what you want to do? I see here that you are expanding the group rows. Are you wanting to just expand group rows and child group rows, or do you want to be able to expand every row in the grid? Which approach you want to take will change the solution slightly.
In general, a group row is going to have two properties that it exposes, get_childGroupRows and get_rows. childGroupRows is going to return all child rows that are also used for grouping and can be expanded like you are doing. get_rows is going to expose an array of child ContainerGridRows which also have the same way of expanding. The difference, however, is that if you want to expand children of a ContainerGridRow then you are going to want to call its get_rowIslands property and iterate over each of the ContainerGrid objects, accessing their rows.
For this latter approach with iterating over container grids it would look something like the following: