Grouping in Code
To group data on a server, do one of the following.
- Call the column’s GridViewDataColumn.GroupBy method.
- Set the column’s GridViewDataColumn.GroupIndex property to a non negative value. This property specifies whether the column takes part in grouping 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);
To group data on a client, use the ASPxClientGridView.GroupBy method.
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.
To ungroup data by the values of a specified column, do the following.
- Call the column’s GridViewDataColumn.UnGroup method.
- Set the column’s GridViewDataColumn.GroupIndex property to -1.
- Call the ASPxGridView’s ASPxGridView.UnGroup method.
To ungroup data on a client, use the ASPxClientGridView.UnGroup method.