I am programmatically adding 2 group by rows to my grid (I would prefer to do this in the Designer but understand this is not possible?) using the following:
grid.DisplayLayout.Bands[0].SortedColumns.Add("ColOne", false, true);grid.DisplayLayout.Bands[0].SortedColumns.Add("ColTwo", false, true);
I would like to have the ColOne group expanded by default, and the ColTwo group collapsed by default.
Nothing I do to programmatically expand/collapse rows has any effect, e.g. grid.ExpandAll(), row.Expanded = true, row.ExpandAll() etc. When I inspect the Rows collection e.g. within InitializeLayout there are no UltraGroupByRows in the collection, only data rows - is this expected? I do see the group by rows on-screen at run-time.
The only thing which has any effect on expanding rows is setting
ultraGridBand1.Override.GroupByRowInitialExpansionState = Infragistics.Win.UltraWinGrid.GroupByRowInitialExpansionState.Expanded; However, that expands both groups whereas I would only like to expand the parent group.
Am I approaching this in the right way, and if so why can't I expand any rows programmatically? Any help appreciated, thanks.
Hi,
P Robinson said:I would prefer to do this in the Designer but understand this is not possible?
It is possible if your data source and data structure exists at design-time.But there's no reason why you can't do it at run-time - although personally, I recommend using the InitializeLayout event of the grid.
P Robinson said:Nothing I do to programmatically expand/collapse rows has any effect, e.g. grid.ExpandAll(), row.Expanded = true, row.ExpandAll() etc. When I inspect the Rows collection e.g. within InitializeLayout there are no UltraGroupByRows in the collection, only data rows - is this expected? I do see the group by rows on-screen at run-time.
The grouping is handled asynchronously. So what's happening here makes sense.You could probably force the rows to be created by forcing the grid to paint by calling grid.Update(). But this is not a great way to do it.
I would do it like this:
void ultraGrid1_InitializeGroupByRow(object sender, InitializeGroupByRowEventArgs e) { if (false == e.ReInitialize && e.Row.Column.Key == "ColOne") { e.Row.Expanded = true; } }
Hi Mike,
This helped me to expend the grouped rows.
Regareds Peter