DxDataGrid<T>.Refresh() Method

Reloads data and redraws the Data Grid component.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

public Task Refresh()

Returns

Type Description
Task

An asynchronous operation that reloads the visible data items and applies changes to the UI.

Remarks

Use the Refresh method to synchronize visible data rows with the latest version of your data source, for example, data from a remote server. This method forces data binding operations and applies the returned version of data source to the Data Grid component.

The code below refreshes the Data Grid when a user clicks the Refresh button:

<DxButton Text="Refresh" Click="@OnRefreshBtnClick" />
<DxDataGrid ... @ref="@_gridRef">
    // ...
</DxDataGrid>
@code {
    DxDataGrid<WebApiOrder> _gridRef;
    protected async Task OnRefreshBtnClick(MouseEventArgs args) {
        await _gridRef.Refresh();
    }
}

The Refresh method does not redraw the rows when there are no changes. In this case, use the StateHasChanged method to re-render the Data Grid, for example, to update templates:

<DxButton Text="Change State" Click="@OnBtnClick" />
<DxDataGrid Data="@forecasts">
    <Columns>
        // ...
        <DxDataGridColumn>
            <DisplayTemplate>
                @DateTime.Now
            </DisplayTemplate>
    </DxDataGridColumn>
    </Columns>
</DxDataGrid>  

@code {
    private WeatherForecast[] forecasts;
    // ...
    protected void OnBtnClick(MouseEventArgs args) {
        StateHasChanged();
    }
}

Run Demo: Data Grid - Data Binding

See Also