Back to Devexpress

Refresh Data

aspnetcore-401024-devextreme-based-controls-concepts-bind-controls-to-data-refresh-data.md

latest1.1 KB
Original Source

Refresh Data

  • Sep 09, 2024

Use the JavaScript API to refresh server-side controls’ data. Any data-bound control has the getDataSource() method. It returns the control’s DataSource instance. Call its reload() method to refresh the control’s data, as shown in the following DataGrid example:

cshtml
@(Html.DevExtreme().DataGrid()
    .ID("targetDataGrid")
    .DataSource(ds => ds.Mvc()
        .Controller("GridData")
        .Key("OrderID")
        .LoadAction("GetOrders")
        .InsertAction("InsertOrder")
        .UpdateAction("UpdateOrder")
        .DeleteAction("DeleteOrder")
    )
)

@(Html.DevExtreme().Button()
    .Text("Refresh Grid")
    .OnClick("reloadData")
)

<script type="text/javascript">
    function reloadData() {
        $("#targetDataGrid").dxDataGrid("getDataSource").reload();
    }
</script>