我正在创建使用此代码使用本地数据源的kendo网格。
var jsondata = [{
abc: "Star Wars: A New Hope",
def: 1977,
ghi: 1977,
jkl: 1977,
mno: 1977,
pqr: 1977
}];
$("div#@code").Grid({
dataSource: {
data: jsondata,
schema: {
model: {
fields: {
abc: { type: "string" },
def: { type: "number" },
ghi: { type: "number" },
jkl: { type: "number" },
mno: { type: "number" },
pqr: { type: "number" }
}
}
},
pageSize: 20
},
height: 430,
scrollable: true,
sortable: true,
filterable: true,
pageable: {
input: true,
numeric: false
},
autoBind: true,
columns: [
{ title: 'abc', field: 'abc' },
{ title: 'def', field: 'def' },
{ title: 'ghi', field: 'ghi' },
{ title: 'jkl', field: 'jkl' },
{ title: 'mno', field: 'mno' },
{ title: 'pqr', field: 'pqr' },
],
});
.Grid是kendoGrid函数的扩展,因为我需要自定义网格。在该函数中,我调用
// Initialize the grid.
kendo.ui.Grid.fn.init.call(that, element, options);
当我测试代码时,浏览器给我的TypeError r未定义。在完成研究之后,这是关于kendo网格试图调用dataSource更新方法的原因,因为我正在使用本地数据源,所以该方法当然不存在。
我是否缺少将剑道网格设置为不读取远程数据源而仅使用本地数据源的选项?
仅供参考,如果数据源是远程的,则网格不会引发错误并且工作正常。
我将您的代码复制粘贴到jsbin http://jsbin.com/qowilugo/1/edit。我只需要更改您的代码的1行即可
$("div#@code").Grid({
进入
$("div#code").kendoGrid({
正如您所解释的,因为Grid函数是您创建的扩展/自定义jquery函数。并且jsbin代码正常运行。
您需要调试扩展名/自定义jquery函数。也许其中一部分代码不符合本地数据源,例如设置serverPaging,serverGrouping,传输选项。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句