This is a migrated thread and some comments may be shown as answers.

Get JSON object model with dataSource.data() without "_events" node

3 Answers 1406 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Guillaume
Top achievements
Rank 1
Guillaume asked on 26 Mar 2012, 04:33 PM
Hello,

Before the new release, if i wanted to get the JSON object model in a data source, i did :
JSON.stringify(myGrid.dataSource.data());
But now, in the JSON string i have also a "_events" node inside it.

So, how can i get real data ?

Here the jsFiddle : http://jsfiddle.net/eyAkP/13/ 

Best Regards,
Guillaume


3 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 26 Mar 2012, 04:38 PM
Hi,

 We seem to have overlooked this. Adding the following snippet will fix that:

kendo.data.ObservableArray.fn.toJSON = function() {
    return [].slice.call(this);


I have updated the jsfiddle: http://jsfiddle.net/korchev/eyAkP/14/

We will fix this for the next release.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Guillaume
Top achievements
Rank 1
answered on 26 Mar 2012, 04:42 PM
Great ! 
Thank you.

Best regards,
Guillaume
0
Valanto
Top achievements
Rank 1
answered on 30 Mar 2012, 01:09 PM
Hi,
This is a great tip! The last update I did to our kendo broke past functionality because we are using the kendo datasource not just along with Kendo components but as a way to wrap our data. This update caused complex JSON objects (with nested objects and arrays of objects inside them) to be polluted by these additional fields. It would be nice if there was a way to fix this across the whole object because now for every sub object I get into I have to call .toJSON().

My current workaround is to have to do
JSON.parse(JSON.stringify(dataSource.data()))


Thanks for your help,
Valanto
Tags
Data Source
Asked by
Guillaume
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Guillaume
Top achievements
Rank 1
Valanto
Top achievements
Rank 1
Share this question
or