Binding existing Kendo grid to a new JSON object
14,071
You could either replace all the data in the DataSource with:
var newData = [ "some", "data", "array" ];
var gridWidget = $('#grid').data("kendoGrid");
gridWidget.dataSource.data(newData);
Or you can give the grid a whole new DataSource (I recommend this approach):
var newData = new kendo.data.DataSource({
data: [ "some", "data", "array" ]
});
var gridWidget = $('#grid').data("kendoGrid");
gridWidget.setDataSource(newData);
and of course newData
in my example would just be whatever data is returned from your function.
Author by
Maven
Updated on June 27, 2022Comments
-
Maven almost 2 years
I have following
kendoGrid
on my page that on load receivesJSON
object from the specified URL.But later i want to bind it to some other
JSON
data received from other source. Is there a way a can bind-refresh existing data containing grid with a newJSON
object?$('#grid').kendoGrid({ sortable: true, groupable: true, scrollable: true, pageable: { pageSizes: 9 }, dataSource: { transport: { read: { url: "../Get/JsonData", dataType: "Json" } } }, columns: [ { field: "name", title: "Name", width: 100 }, ... ... ] });