javascript - 更新后刷新网格不起作用

标签 javascript kendo-ui kendo-grid

我有以下剑道网格,更新后我希望从数据源再次刷新我的网格,但不适用于以下方法我不确定我是否将刷新数据源命令放在正确的位置,任何帮助都会受到高度赞赏

 dataSource = new kendo.data.DataSource({
                        transport: {
                            read: function (options) {
                                options.success(result); // where data is the local data array
                            },
                            update: function (options) {

                                $.ajax({
                                    type: "POST",
                                    url: "/AdminTool/update_grid",
                                    data: options.data.models[0],
                                    dataType: "json",
                                    success: function (data) {
                                        options.success(data);
                                        // alert("success");
                                        $("#turbingrid").data("kendoGrid").dataSource.read();

                                    },
                                    error: function (data) {
                                        options.error(data);
                                        //  alert("error");
                                    },
                                });

                            },

                            parameterMap: function (options, operation) {
                                if (operation !== "read" && options.models) {
                                    return { models: kendo.stringify(options.models) };
                                }
                            }
                        },
                        batch:true,
                        pageSize: 40,
                        schema: {
                            //data: employee,
                            model: {
                                id: "DeviceIP",
                                fields: {
                                    DeviceIP: { editable: false, nullable: true },
                                    //Producer: { type:"string" },
                                    //3 Model: { type: "string" },
                                    DeviceType:{ type:"string" },
                                    Description:{ type:"string" },
                                    Username:{ type:"string" },
                                    Password:{ type:"string" },
                                    PublicIP: { type: "string" },
                                    ModelProducer: { type: "string" },
                                    TurbineId: {type:"string"}
                                    //UnitPrice: { type: "number", validation: { required: true, min: 1} },
                                    //Discontinued: { type: "boolean" },
                                    //UnitsInStock: { type: "number", validation: { min: 0, required: true } }
                                }
                            }
                        }


                    });

最佳答案

我用过

$("#turbingrid").data("kendoGrid").dataSource.data(data);

代替

$("#turbingrid").data("kendoGrid").dataSource.read();

将检索到的数据加载到剑道网格。希望能帮助到你。

关于javascript - 更新后刷新网格不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45860557/

相关文章:

javascript - 在 Xamarin.Forms WebView 中执行 Javascript

javascript - 在不使用循环或 jQuery 的情况下获取数组或 JSON 中选择的选项值列表

json - Kendo 数据源 View 和数据方法之间的区别

kendo-ui - 从 Kendo 网格数据填充 Kendo Treeview

javascript - kendo 图表在 y 轴上以 dd/MM/yyyy 显示日期

asp.net-mvc-5 - jQuery.Deferred 异常 : Kendo is not defined ReferenceError: Kendo is not defined

asp.net-mvc - 弹出编辑模式下的多列

javascript - @compated 属性循环检测到错误

jquery - Kendo UI 格式化日期和时间字段

javascript - 当 catch 存在时,可能会出现未处理的 promise 拒绝