DxGridDataColumn.GroupIndex Property

Specifies the column’s index among grouped columns.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

[Parameter]
public int GroupIndex { get; set; }

Property Value

Type Description
Int32

The column’s index (zero-based) among grouped columns. -1 if the grid does not group data by this column.

Remarks

Use the GroupIndex property to group data by an individual column in code. In this case, grouping is applied regardless of the DxGrid.ShowGroupPanel, DxGrid.AllowGroup, and DxGridDataColumn.AllowGroup property values.

If you group data by multiple columns, this property specifies the group level. The lower the value, the higher a column’s group level. For instance, the grid first groups data by a column with GroupIndex = 0 and then by a column with GroupIndex = 1. If you set this property to -1, data is not grouped by the corresponding column.

@using Microsoft.EntityFrameworkCore
@using Grid.Northwind
@inject NorthwindContext Northwind

<DxGrid Data="GridDataSource"
        ShowGroupPanel="true"
        CustomizeCellDisplayText="OnCustomizeCellDisplayText">
    <Columns>
        <DxGridDataColumn FieldName="OrderDate"
                      DisplayFormat="d"
                      GroupIndex="0"
                      GroupInterval="GridColumnGroupInterval.DateMonth"/>
        <DxGridDataColumn FieldName="Customer"
                      SortMode="GridColumnSortMode.DisplayText"
                      GroupIndex="1"
                      GroupInterval="GridColumnGroupInterval.DisplayText" />
        <DxGridDataColumn FieldName="Freight"
                      DisplayFormat="n2" />
    </Columns>
</DxGrid>

@code {
    object GridDataSource { get; set; }

    protected override void OnInitialized() {
        GridDataSource = Northwind.Orders
            .Include(i => i.Customer)
            .Include(i => i.OrderDetails)
            .Include(i => i.ShipViaNavigation)
            .ToList();
    }

    void OnCustomizeCellDisplayText(GridCustomizeCellDisplayTextEventArgs e) {
        if (e.FieldName == "Customer")
        {
            var customer = (Customer)e.Value;
            e.DisplayText = $"{customer.CompanyName} ({customer.Country}, {customer.City})";
        }
    }
}

Grid - GroupIndex

Run Demo: Grid - Group Data

Implements

See Also