更新后刷新网格不起作用

Posted

技术标签:

【中文标题】更新后刷新网格不起作用【英文标题】: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 函数? 【参考方案1】:

我用过

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

而不是

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

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

【讨论】:

我应该把它放在哪里? 就在你放 $("#turbingrid").data("kendoGrid").dataSource.read(); 就我而言,我从未按照您的方式更新剑道数据源。我只是单独发起ajax调用,然后用上面的代码更新网格。 javascript 运行时错误:对象不支持属性或方法“切片”我明白了 试试这个:***.com/questions/32104024/…

以上是关于更新后刷新网格不起作用的主要内容,如果未能解决你的问题,请参考以下文章

[ajax自动刷新更新面板后,jquery不起作用

DoJo 增强的网格动态更新约束不起作用

Snowpack & React:热重装/刷新不起作用

更新面板更新()方法不起作用,如何在函数内强制刷新页面

角度智能表 - 分页对刷新数据对象不起作用

AndroidAnnotations 更新到 3.0.1 不起作用