【问题标题】:refreshing grid after update does not work更新后刷新网格不起作用
【发布时间】:2018-02-02 06:34:09
【问题描述】:

我有以下剑道格,更新后,我想我的网再次被刷新,从数据源,但不与下面的办法IM工作不知道,如果IMM将刷新数据源命令,在正确的地方,任何帮助将不胜感激

 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.read();
  • @Daniel 是的
  • 根据你的版本,this might be useful,你试过了吗?
  • @Daniel 我应该把这段代码放在哪里?
  • 视情况而定,options.success 是 synchronous 还是 asynchronous 函数?

标签: javascript kendo-ui kendo-grid


【解决方案1】:

我用过

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

而不是

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

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

【讨论】:

  • 我应该把它放在哪里?
  • 就在你放 $("#turbingrid").data("kendoGrid").dataSource.read();
  • 就我而言,我从未按照您的方式更新剑道数据源。我只是单独发起ajax调用,然后用上面的代码更新网格。
  • JavaScript 运行时错误:对象不支持属性或方法“切片”我明白了
猜你喜欢
  • 2012-09-10
  • 2023-03-27
  • 1970-01-01
  • 2019-01-23
  • 2019-09-13
  • 1970-01-01
  • 1970-01-01
  • 2016-06-22
  • 1970-01-01
相关资源
最近更新 更多