Skip to main content

DxGrid.AutoCollapseDetailRow Property

Specifies whether an expanded detail row should be automatically collapsed when a user expands another detail row.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

Declaration

[DefaultValue(false)]
[Parameter]
public bool AutoCollapseDetailRow { get; set; }

Property Value

Type Default Description
Boolean false

true to automatically collapse an expanded detail row; otherwise, false.

Remarks

Specify the DetailRowTemplate to enable a master-detail relationship in the grid. To collapse an expanded detail row when a new detail row is displayed, set the AutoCollapseDetailRow property to true.

@inject NwindDataService NwindDataService

<DxGrid @ref="Grid" Data="MasterGridData" AutoCollapseDetailRow="true">
    <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>

@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);
        }
    }
}

Grid - Auto Collapse Detail Rows

Run Demo: Grid Master-Detail View - Nested Grid View Example: Grid for Blazor - Create a Master-Detail Layout View Example: Master-Detail with partial loading

See Also