Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxGrid.IsGroupRowExpanded(Int32) Method

Specifies whether the specified group row is expanded.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public bool IsGroupRowExpanded(
    int visibleIndex
)

#Parameters

Name Type Description
visibleIndex Int32

The row’s visible index.

#Returns

Type Description
Boolean

true if the specified row is expanded; otherwise, false.

#Remarks

Note

The Grid bound to an Instant Feedback Data Source or GridDevExtremeDataSource loads data asynchronously in small portions (instead of the entire dataset). Before you call the IsGroupRowExpanded method, call the WaitForRemoteSourceRowLoadAsync(Int32) method to ensure that the specified data row is loaded.

The following code snippet checks whether row 2 is a group row and if it is expanded.

@using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
@implements IDisposable

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

<p></p>
<DxButton Click="@(() => MyGrid.GroupBy("OrderDate"))">Group by Order Date</DxButton>

<p></p>
<DxButton Click="@OnIsGroupRow">Check if the Row 2 is a group row</DxButton>

@Alert

@code {
    IGrid MyGrid { get; set; }
    object GridDataSource { get; set; }
    NorthwindContext Northwind { get; set; }
    string Alert;

    protected override void OnInitialized() {
        Northwind = NorthwindContextFactory.CreateDbContext();
        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})";
        }
    }

    void OnIsGroupRow() {
        if (MyGrid.IsGroupRow(2)) {
            if (MyGrid.IsGroupRowExpanded(2) == true)
                Alert = "Row 2 is a group row. The row is expanded.";
            else
                Alert = "Row 2 is a group row. The row is collapsed.";
        }
        else {
            Alert = "Row 2 is not a group row";
        }
    }

    public void Dispose() {
        Northwind?.Dispose();
    }
}

Blazor Grid Page Size Selector

For more information about data grouping in the Grid component, refer to the following topic: Group Data in Blazor Grid.

See Also