IDataGridDetailRows.IsRowExpanded(Object) Method

Specifies whether the specified detail row is expanded.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

bool IsRowExpanded(
    object key
)

Parameters

Name Type Description
key Object

The detail row or the key that identifies the detail row.

Returns

Type Description
Boolean

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

Remarks

Use the CollapseRow(Object) and ExpandRow(Object) methods to collapse and expand detail rows in code.

The IsRowExpanded method can accept one of the following:

  • The data item that corresponds to the detail row.

    <DxDataGrid @ref="@grid"
                DataAsync="@SalesViewerDataProvider.GetProducts"
                ShowDetailRow="true"
                RowClick="@OnRowClick">
        @*...*@
        <DetailRowTemplate Context="dataItem">
            @*...*@
        </DetailRowTemplate>
    </DxDataGrid>
    
    @code {
        // ...
        void OnRowClick(DataGridRowClickEventArgs<Product> args) {
            if (grid.DetailRows.IsRowExpanded(args.DataItem))
                grid.DetailRows.CollapseRow(args.DataItem);
            else grid.DetailRows.ExpandRow(args.DataItem);
        }
    }
    
  • The key that identifies the detail row. In this case, you should specify the KeyFieldName property.

    <DxDataGrid @ref="@grid"
                DataAsync="@SalesViewerDataProvider.GetProducts"
                ShowDetailRow="true"
                RowClick="@OnRowClick"
                KeyFieldName="Id">
        @*...*@
        <DetailRowTemplate Context="dataItem">
            @*...*@
        </DetailRowTemplate>
    </DxDataGrid>
    
    @code {
        // ...
        void OnRowClick(DataGridRowClickEventArgs<Product> args) {
            if (grid.DetailRows.IsRowExpanded(args.DataItem.Id))
                grid.DetailRows.CollapseRow(args.DataItem.Id);
            else grid.DetailRows.ExpandRow(args.DataItem.Id);
        }
    }
    

Run Demo: Data Grid - Master-Detail View

See Also