IDataGridDetailRows.ExpandRow(Object) Method

Expands the specified detail row.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

void ExpandRow(
    object key
)

Parameters

Name Type Description
key Object

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

Remarks

Use the IsRowExpanded(Object) property to check whether the row is expanded. To collapse the detail row in code, call the CollapseRow(Object) method.

The ExpandRow 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);
        }
    }
    

Use the ExpandedStateChanged event to handle changes of a detail row’s expand state.

Run Demo: Data Grid - Master-Detail View

See Also