ASPxGridView.GroupBy(GridViewColumn) Method
Groups data by the values of the specified column.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v19.1.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
column | GridViewColumn | A GridViewColumn descendant that represents the data column within the ASPxGridView. |
Returns
Type | Description |
---|---|
Int32 | An integer value that specifies the grouping level. |
Remarks
The ASPxGridView supports grouping data by an unlimited number of data columns. To group data by the values of the specified column, use the GroupBy method. You can also use the column’s GridViewDataColumn.GroupBy method.
Calling the GroupBy method has no effect if data is already grouped by the values of the specified column. If several columns are involved in grouping, the column will reside at the bottom grouping level which is returned by the GroupBy method.
Data rows are always sorted against the grouping columns. If data is grouped against a column which isn’t sorted, the ASPxGridView automatically applies sorting in ascending order to the column.
To ungroup data by the values of a single column, use the ASPxGridView.UnGroup method or the column’s GridViewDataColumn.UnGroup method.
Data grouping is allowed if the ASPxGridViewBehaviorSettings.AllowGroup and ASPxGridBehaviorSettings.AllowSort properties are set to true.
Example
<dx:ASPxComboBox runat="server" ID="cbFields" ValueType="System.Int32" SelectedIndex="0" Theme="MaterialCompactOrange" Caption="Group by">
<Items>
<dx:ListEditItem Text="Country" Value="0" />
<dx:ListEditItem Text="Country, City" Value="1" />
<dx:ListEditItem Text="Company Name" Value="2" />
</Items>
<ClientSideEvents SelectedIndexChanged="function(s) { grid.PerformCallback(s.GetValue()) }" />
</dx:ASPxComboBox>
<dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" DataSourceID="CustomersDataSource"
KeyFieldName="CustomerID" OnCustomCallback="grid_CustomCallback" Width="100%">
<Columns>
<dx:GridViewDataColumn FieldName="ContactName" />
<dx:GridViewDataColumn FieldName="CompanyName" />
<dx:GridViewDataColumn FieldName="City" />
<dx:GridViewDataColumn FieldName="Region" />
<dx:GridViewDataColumn FieldName="Country" />
</Columns>
<Settings ShowGroupPanel="true" />
</dx:ASPxGridView>
For a full example, see Grid - Grouping Data demo.
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the GroupBy(GridViewColumn) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.