Reputation: 49
I am facing the same problem that i was going through in the previuos questions asked in stack overflow with no success answer, can anyone please guide me. Kendo ui datasource refresh?
I am using angular js to bind the grid, say i am showing column " jan2016, feb2016" these two cilumns shows perfectly, but when i go back and select one more month "mar2016", the grid doesnt refresh showing the mar2016
I used k-rebind, datasource.read(), datasource.refresh()... nothign works
Thanks in advance Ram
Upvotes: 1
Views: 1466
Reputation: 1940
While Erick's answer will likely work, instead of destroying in recreating your kendo widget, first try doing
$("#grid").data("kendoGrid").setDataSource(datasource)
It's much less code and it's a cleaner way of changing the datasource
Upvotes: 1
Reputation: 1583
I had the exact same problem and struggled getting an answer from stack and kendo Forums, what I came up with was the following:
First I store the data source by saving the response object in new object
var DataSourceObj = new []; //some ajax response
Then I destroy the grid completely
var grid = $("#grid").data("kendoGrid");
grid.destroy();
Then I reinitialize the grid and bind the DataSourceObj (Usually put it in function closure to bind it in mutliple places)
function initGrid(datasource) {
$("#grid").kendoGrid({
selectable: "row",
allowCopy: true,
columns: [
{ field: "productName" },
{ field: "category" }
],
dataSource: datasource, // bind here
pageable: {
pageSize: 10
}
});
}
//call initGrid and pass datasource
initGrid(DataSourceObj);
hope this works for you man :)
Upvotes: 0