【发布时间】:2013-04-02 19:58:41
【问题描述】:
我想创建一个带有动态列的剑道网格,所有列都将在客户端创建。
举个例子:
我已经编写了以下代码来创建一个网格:
var grid = $("#grid");
grid.children().remove();
grid.kendoGrid({
columns: [{ title: 'One', width: '100px' }, { title: 'Two', width: '100px' }, {title: 'Three', width:'100px'}],
dataSource: {
transport: {
read: {
url: "@Url.Action("")",
type: "GET",
dataType: "json",
traditional: true,
data: {
itemTypeId: $("#").val(),
where: ["", "", "", "", ""],
orderBy: ["", "", ""],
},
},
},
schema: {
data: "",
total: "",
},
serverPaging: true,
pageSize: 4,
error: function (e) {
alert(e.errors);
}
},
pageable: true,
resizable: true,
reorderable: true,
})
}
当我定义列时:
columns: [{ title: 'One', width: '100px' }, { title: 'Two', width: '100px' }, {title: 'Three', width:'100px'}],
以上代码运行良好。
但我想在一个不起作用的循环中创建所有这些列。
喜欢: 我将模式保存在 javascript 变量中,然后将其分配给剑道网格。
Var columnSchema = "{ title: 'One', width: '100px' },{ title: 'Two', width: '100px' },{ title: 'Two', width: '100px' }";
columns : [columnSchema]
但它不起作用。
【问题讨论】:
标签: kendo-grid