aspnet-devexpress-dot-web-dot-gridviewdatacolumn-dd62ff4a.md
Specifies the column’s grouping level.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
[DefaultValue(-1)]
public int GroupIndex { get; set; }
<DefaultValue(-1)>
Public Property GroupIndex As Integer
| Type | Default | Description |
|---|---|---|
| Int32 | -1 |
The column’s grouping level.
-1 if the grid does not group its data by the column.
|
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.
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);
}
Protected Sub grid_BeforeColumnSortingGrouping(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxGridView.ASPxGridViewBeforeColumnGroupingSortingEventArgs)
If e.Column.Name = "VisibleProductName" Then grid.Columns("InvisibleProductName").Visible = ((TryCast(grid.Columns("VisibleProductName"), GridViewDataColumn)).GroupIndex <> -1)
End Sub
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.
{
return Grid.DataColumns.Where(c => c.GroupIndex == -1 && c.Visible);
}
See Also