ASPxGridView.GroupBy(GridViewColumn, Int32) Method
Groups data by the values of the specified data column and defines the column’s grouping level.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
NuGet Package: DevExpress.Web
#Declaration
public int GroupBy(
GridViewColumn column,
int value
)
#Parameters
Name | Type | Description |
---|---|---|
column | Grid |
A grid column. |
value | Int32 | The column’s grouping level. |
#Returns
Type | Description |
---|---|
Int32 | The column’s grouping level. |
#Remarks
When you call the server-side GroupBy(GridViewColumn, Int32)
method, the grid behaves as follows:
Keeps the previous grouping and adds the column to the collection of grouped columns.
Sets the
GroupIndex
property to the specified grouping level.
To clear grouping applied to a particular column on the server side, call the ASPxGridView.UnGroup or GridViewDataColumn.UnGroup method.
For more information on grouping in the grid, refer to the following topic: ASPxGridView - Group Data.
<dx:ASPxGridView ID="grid" runat="server" AutoGenerateColumns="False" KeyFieldName="CustomerID"
OnCustomCallback="grid_CustomCallback">
<Columns>
<dx:GridViewDataTextColumn FieldName="CompanyName" VisibleIndex="0" />
<dx:GridViewDataTextColumn FieldName="ContactName" VisibleIndex="1" />
<dx:GridViewDataTextColumn FieldName="Country" VisibleIndex="2" />
<dx:GridViewDataTextColumn FieldName="City" VisibleIndex="3" />
<dx:GridViewDataTextColumn FieldName="Region" VisibleIndex="4" />
</Columns>
<Settings ShowGroupPanel="true" />
</dx:ASPxGridView>
protected void grid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) {
grid.GroupBy((GridViewDataColumn)grid.Columns["Country"], 0);
grid.GroupBy((GridViewDataColumn)grid.Columns["City"], 1);
}