Skip to main content

Refresh Data

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:

@(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>