Skip to main content
Tab

GridViewDataColumn.GroupIndex Property

Specifies the column’s grouping level.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

[DefaultValue(-1)]
public int GroupIndex { get; set; }

Property Value

Type Default Description
Int32 -1

The column’s grouping level.
-1 if the grid does not group its data by the column.

Remarks

ASPxGridView allows users to group its data by multiple columns. Specify the GroupIndex property to define the column’s grouping level. If the GroupIndex property is set to -1, the control does not group its data by this column.

For more information on grouping in the grid, refer to the following topic: ASPxGridView - Group Data.

View Example: How to select/deselect all rows in a group when Grid View data is grouped by one column

Example

The example below demonstrates how to group records by first letters:

<dx:ASPxGridView ID="grid" runat="server" AutoGenerateColumns="False" 
    KeyFieldName="ProductID" OnBeforeColumnSortingGrouping="grid_BeforeColumnSortingGrouping">
    <Columns>
        <dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="0">
            <EditFormSettings Visible="False" />
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn Name="VisibleProductName" FieldName="ProductName" VisibleIndex="1">
            <Settings AllowGroup="True" SortMode="Custom" />
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn Name="InvisibleProductName" FieldName="ProductName" VisibleIndex="2"
            Visible="False" />
        <dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="2" />
    </Columns>
    <Settings ShowGroupPanel="True" />
</dx:ASPxGridView>
protected void grid_BeforeColumnSortingGrouping(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewBeforeColumnGroupingSortingEventArgs e) {
    if(e.Column.Name == "VisibleProductName")
        grid.Columns["InvisibleProductName"].Visible = ((grid.Columns["VisibleProductName"] as GridViewDataColumn).GroupIndex != -1);
}

ASPxGridView - BeforeSortingGrouping

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GroupIndex property.

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.

See Also