The grid has been initialized, so:
$(document).ready(function()
{
$("#foo-grid").kendoGrid(
{ height: 360,
groupable: false,
scrollable: true,
sortable: true,
pageable: true,
columns:[
{
field: "id",
title: "id"
},
{
field: "baz",
title: "chosen"
}
]
});
});
And later, based on user-interaction with the page, some data are fetched in JSON format from a generic handler (ashx) and are passed to the function below, in the params object:
function populateGrid(event, params) {
// at this juncture, examination in the debugger confirms that params.data contains an array of json objects
// [ {"id":1, "baz": true }, {"id":2, "baz": true}, {"id":3, "baz": false},.{"id":4, "baz": true }]
var grid = $("#foo-grid).data("kendoGrid"); // get a handle to the grid
grid.dataSource = { data: params.data, pageSize: 25 };
}
I get a handle to the grid and then assign its dataSource object via the API, but nothing happens. Instead of instantiating the grid when the document is ready and then later trying to set its dataSource, should I wait to instantiate the grid object inside the function above and populate it all in one fell swoop? If so, how do I completely destroy the grid? The user may make multiple queries, and the grid would then have to be reinstantiated and repopulated several times.
$(document).ready(function()
{
$("#foo-grid").kendoGrid(
{ height: 360,
groupable: false,
scrollable: true,
sortable: true,
pageable: true,
columns:[
{
field: "id",
title: "id"
},
{
field: "baz",
title: "chosen"
}
]
});
});
And later, based on user-interaction with the page, some data are fetched in JSON format from a generic handler (ashx) and are passed to the function below, in the params object:
function populateGrid(event, params) {
// at this juncture, examination in the debugger confirms that params.data contains an array of json objects
// [ {"id":1, "baz": true }, {"id":2, "baz": true}, {"id":3, "baz": false},.{"id":4, "baz": true }]
var grid = $("#foo-grid).data("kendoGrid"); // get a handle to the grid
grid.dataSource = { data: params.data, pageSize: 25 };
}
I get a handle to the grid and then assign its dataSource object via the API, but nothing happens. Instead of instantiating the grid when the document is ready and then later trying to set its dataSource, should I wait to instantiate the grid object inside the function above and populate it all in one fell swoop? If so, how do I completely destroy the grid? The user may make multiple queries, and the grid would then have to be reinstantiated and repopulated several times.