3
我想创建一个具有动态列的kendo网格,所有列都将在客户端创建。在Kendo Grid中创建动态列(Javascript)
为例:
我已经写下面的代码来创建一个网格:
columns: [{ title: 'One', width: '100px' }, { title: 'Two', width: '100px' }, {title: 'Three', width:'100px'}],
以上:
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,
})
}
当我通过定义列代码工作正常。
但我想创建所有这些列在一个不工作的循环。
like: 我在JavaScript变量中保存模式,然后将其分配给剑道网格。
Var columnSchema = "{ title: 'One', width: '100px' },{ title: 'Two', width: '100px' },{ title: 'Two', width: '100px' }";
columns : [columnSchema]
但它不工作。