I want to create a kendo grid with dynamic column all the columns will be create on client side.
as an example:
I have written the below code to create a grid :
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,
})
}
When i define the column by :
columns: [{ title: 'One', width: '100px' }, { title: 'Two', width: '100px' }, {title: 'Three', width:'100px'}],
the above code is working fine.
But I want to create all these column in a loop which is not working.
like as : I am holding the schema in a javascript variable and then assigning it to the kendo grid.
Var columnSchema = "{ title: 'One', width: '100px' },{ title: 'Two', width: '100px' },{ title: 'Two', width: '100px' }";
columns : [columnSchema]
But it is not working.