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

DxGrid.EndUpdate() Method

Resumes Grid updates (when the BeginUpdate() method pauses updates) and re-renders the Grid.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v23.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public void EndUpdate()

Remarks

You can use the BeginUpdate() and EndUpdate methods to complete the following tasks:

Make Multiple Grid Modifications

The Grid is re-rendered after each modification that affects its appearance and/or functionality (for instance, if you change sort or group options in code).

When you make a sequence of modifications that cause the Grid to update, enclose your code between the BeginUpdate and EndUpdate method calls. The BeginUpdate method locks the Grid, while the EndUpdate method unlocks and redraws the Grid. This allows you to avoid excessive render operations and improve the Grid’s overall performance.

The following code snippet changes multiple sort options in the Grid:

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

<DxGrid Data="@Data" @ref="MyGrid">
    <Columns>
        <DxGridDataColumn FieldName="Country" SortIndex="0" />
        <DxGridDataColumn FieldName="City" SortIndex="1" />
        <DxGridDataColumn FieldName="OrderDate" />
        <DxGridDataColumn FieldName="UnitPrice" DisplayFormat="c" />
        <DxGridDataColumn FieldName="Quantity" />
    </Columns>
</DxGrid>
<br />

<DxButton Click="@(() => ChangeSortInfo())">Change Sort Options</DxButton>

@code {
    object Data { get; set; }
    NorthwindContext Northwind { get; set; }
    IGrid MyGrid { get; set; }

    protected override void OnInitialized() {
        Northwind = NorthwindContextFactory.CreateDbContext();
        Data = Northwind.Invoices
            .ToList();
    }

    void ChangeSortInfo() {
        MyGrid.BeginUpdate();
        MyGrid.ClearSort();
        MyGrid.SortBy("OrderDate");
        MyGrid.SortBy("UnitPrice", GridColumnSortOrder.Descending);
        MyGrid.EndUpdate();
    }

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

Blazor Grid Multiple Changes

Specify Grid Parameters

You can change values of the Grid’s parameters outside the component’s markup. To do this, enclose your code between the BeginUpdate and EndUpdate method calls. Otherwise, an exception occurs.

The following snippet changes the AllowSort parameter value to enable and disable data sorting:

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

<DxGrid Data="@Data" @ref="MyGrid">
    <Columns>
        <DxGridDataColumn FieldName="Country" />
        <DxGridDataColumn FieldName="City" />
        <DxGridDataColumn FieldName="OrderDate" />
        <DxGridDataColumn FieldName="UnitPrice" DisplayFormat="c" />
        <DxGridDataColumn FieldName="Quantity" />
    </Columns>
</DxGrid>
<br/>

<DxButton Click="@(() => SetAllowSort(false))">Disable Sorting</DxButton>
<DxButton Click="@(() => SetAllowSort(true))">Enable Sorting</DxButton>

@code {
    object Data { get; set; }
    NorthwindContext Northwind { get; set; }
    IGrid MyGrid { get; set; }

    protected override void OnInitialized() {
        Northwind = NorthwindContextFactory.CreateDbContext();
        Data = Northwind.Invoices
            .ToList();
    }

    void SetAllowSort (bool value) {
        MyGrid.BeginUpdate();
        MyGrid.AllowSort = value;
        MyGrid.EndUpdate();
    }

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

Blazor Grid Change Parameters In Code

Implements

See Also