Grouping in Code
Do one of the following to group data on the server side:
- Call the column’s GridViewDataColumn.GroupBy method.
- Set the column’s GridViewDataColumn.GroupIndex property to a non-negative value. This property specifies whether users can use the column to group data and at which level.
- Call the ASPxGridView’s ASPxGridView.GroupBy method.
Example
The following code shows how to group by two columns (“Country” and “City”).
The image below shows the result.
((GridViewDataColumn)ASPxGridView1.Columns["City"]).GroupBy();
ASPxGridView1.GroupBy(ASPxGridView1.Columns["Country"], 0);
Use the ASPxClientGridView.GroupBy method to group data on the client side.
To prevent grouping, handle the ASPxClientGridView.ColumnGrouping client event. The processed client column is identified by the event parameter’s column property. To cancel the operation, set the cancel property to true
.
Do one of the following to ungroup data grouped by a column:
- Call the column’s GridViewDataColumn.UnGroup method.
- Set the column’s GridViewDataColumn.GroupIndex property to -1.
- Call the ASPxGridView’s ASPxGridView.UnGroup method.
Use the ASPxClientGridView.UnGroup method to ungroup data on the client side.