【发布时间】:2016-11-15 20:10:06
【问题描述】:
我有这样的剑道网格列:
$("#lstCategory").kendoGrid({
dataSource: {
data: info,
autoSync: true,
schema: {
model: {
fields: {
category: { editable: false, type: "string" },
subCategory: { editable: false, type: "string" }
}
}
},
pageSize: 7,
group: {
field: "category",
aggregates: [
{ field: "category", aggregate: "count" }
]
}
},
sortable: true,
scrollable: false,
pageable: true,
editable: true,
columns: [
{ field: "category", title: "Categoría", aggregates: ["count"], groupFooterTemplate: "Total: #=count#" },
{ field: "subCategory", title: "Subcategoria" },
{ command: "destroy", title: "", width: "150px" }
]
});
}
在那里我添加了用于发布操作的字段。问题是我想在发布后重置此网格以刷新它并插入另一个值我尝试使用下一个命令:
$("#lstCategory").empty(); // this one dissapear kendo grid
$('#lstCategory').data('kendoGrid').refresh();
$('#lstCategory').data().kendoGrid.destroy();
但他们都没有在发布后刷新我的剑道,这可能是什么问题?
更新:
尝试作为恐惧海盗答案:
在发布操作后我发送这个:
var grid = $("#lstCategory").getKendoGrid();
var info = refeshInfoFromServer();
grid.dataSource.data(info);
function refeshInfoFromServer() {
return $("#lstCategory").data("kendoGrid").dataSource.read();
}
它似乎可以工作,但我的页面在加载时卡住了。 Google Chrome Inspector 回归
kendo.all.min.js:11 Uncaught TypeError: e.slice is not a function
【问题讨论】:
-
当您的架构与您从服务器或给定对象列表中获取的对象不匹配时,将引发切片错误。您需要定义来自哪些属性数据。如果您不指定它可以使用一些默认值。 docs.telerik.com/kendo-ui/api/javascript/data/datasource
-
这不是我的建议...您需要从服务器重新填充信息无论您第一次如何完成。 info = grid.dataSource.read() 作为 read() 方法不可能返回 Promise not 数据。因此,您现在正在做的是将 dataSource 的数据设置为 Promise ...这甚至无法远程工作,这就是您收到切片错误的原因...因为切片正在您的 Promise 上被调用推到那里而不是合法的数据数组。您首先需要向我们展示信息是如何填充的。
标签: jquery kendo-ui kendo-grid