How can I refresh the grid after I edit the Kendo UI grid?

后端 未结 11 1781
忘掉有多难
忘掉有多难 2021-02-01 15:09

I edit the grid using editable: \"popup\" as shown on Telerik\'s demo page. After I edit the grid, I want the grid to refresh. Does the grid have any event that is

11条回答
  •  庸人自扰
    2021-02-01 16:06

    The accepted answer can cause unexpected behaviour if you're using server side validation. The sync event triggers whenever an update is sent to the server regardless of whether the request was successful, so if the request triggers server side validation errors (or any other errors) the grid will still be updated and any changes lost. Still looking at the this but the best solution I've found is to use the data source's onRequestEnd() event and manually check for errors.

    For example:

    function onRequestEnd(e)
    {
        var grid = $("#grid").data("kendoGrid");
        var data = grid.dataSource;
        if (e.type == "create" || e.type == "update") {
            if (!e.response.Errors) 
                data.read();
            else console.log("I had some issues");
        }
    }
    

提交回复
热议问题