我有劍道網格列如下:復位劍道網格列
$("#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
片引發錯誤。您需要定義數據來自哪些屬性。如果您沒有指定它使用某個默認值。 http://docs.telerik.com/kendo-ui/api/javascript/data/datasource – Ademar
這不是我所建議的......你需要重新填充服務器中的信息*但是你第一次使用它*。沒有辦法info = grid.dataSource.read(),因爲read()方法返回一個Promise * not *數據。所以,你現在正在做的是將dataSource的數據設置爲Promise ...,它甚至不能遠程工作,這就是爲什麼你得到了切片錯誤......當切片在Promise上被調用時而不是合法的數據陣列。您需要向我們展示信息是如何填充的。 –