I have a webgrid with 10 columns and 20 rows of data. The grouping style is set to outlook.
It seems that, if I group by a column, I am unable to expand the rows in the same method/event handler call.
For example, if I place a button on the page with the following event handler:
protected void Button1_Click(object sender, EventArgs e) { UltraWebGrid1.Columns[3].IsGroupByColumn = true; foreach (UltraGridRow r in UltraWebGrid1.Rows) { r.Expand(true); } }
I need to click the button twice in order that the rows are expanded.
Is this supposed to be happening??
Regards
AM
This could be something that is expected, since setting IsGroupByColumn just sets a property, while the actual grouping take place much later in the page life-cycle. So any expanded rows will be collapsed again for the group.
Is it possible to move the row exansion code at a later point in your page life cycle (say, OnPreRender) and see how it goes? You can also play with the InitializeLayout event of the grid and see if it is executed at a later point than the Button_Click event handler.
Ok.
I have changed the code to include a call to the PerformGroupRows method.
protected void Button1_Click(object sender, EventArgs e) { UltraWebGrid1.Columns[3].IsGroupByColumn = true; UltraWebGrid1.PerformGroupRows(); UltraWebGrid1.ExpandAll(true); }
The button click now works.
I then placed the code in an event handler for the PreRenderComplete event.
It now works on page load.