Skip to main content
A newer version of this page is available. .

DxGrid.CollapseAllDetailRows() Method

Collapses all detail rows.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public void CollapseAllDetailRows()

Remarks

Specify the DetailRowTemplate to enable a master-detail relationship in the grid. If the AutoCollapseDetailRow property is set to false (the default value), a user can expand multiple detail rows simultaneously. To collapse all expanded detail rows, use the CollapseAllDetailRows method.

@inject NwindDataService NwindDataService

<DxGrid @ref="Grid" 
        Data="MasterGridData" >
    <Columns>
        <DxGridDataColumn FieldName="ContactName" SortIndex="0" />
        <DxGridDataColumn FieldName="CompanyName" />
        <DxGridDataColumn FieldName="Country" />
        <DxGridDataColumn FieldName="City" />
    </Columns>
    <DetailRowTemplate>
        <Grid_MasterDetail_NestedGrid_DetailContent Customer="(Customer)context.DataItem" />
    </DetailRowTemplate>
</DxGrid>

<DxButton Click="OnButtonClick" Text="Collapse All Detail Rows" />

@code {
    IGrid Grid { get; set; }
    object MasterGridData { get; set; }

    protected override async Task OnInitializedAsync() {
        MasterGridData = await NwindDataService.GetCustomersAsync();
    }

    protected override void OnAfterRender(bool firstRender) {
        if(firstRender) {
            Grid.ExpandDetailRow(0);
        }
    }

     void OnButtonClick() {
            Grid.CollapseAllDetailRows();
        }
}

To collapse an individual detail row, call the CollapseDetailRow(Int32) method.

See Also