How to get the displayed data of KendoGrid in json format?

user677607 picture user677607 · Apr 26, 2012 · Viewed 76.2k times · Source

I have a kendoGrid and i would like to get the JSON out of it after filtering and sorting how do I achieve this?

something like the following,

var grid = $("#grid").data("kendoGrid");

alert(grid.dataSource.data.json); // I could dig through grid.dataSource.data and I see a function ( .json doen't exist I put it there so you know what i want to achieve )

Thanks any help is greatly appreciated!

Answer

Petur Subev picture Petur Subev · Apr 28, 2012

I think you're looking for

var displayedData = $("#YourGrid").data().kendoGrid.dataSource.view()

Then stringify it as follows:

var displayedDataAsJSON = JSON.stringify(displayedData);

Hope this helps!