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

Kendo data format compatibility with Tastypie/Django backend

2 Answers 590 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Wes
Top achievements
Rank 1
Wes asked on 13 Oct 2012, 12:16 PM
My apologies if this has been covered before, but I searched and did not see exactly this issue. I've placed this in the Grid forum, but maybe that's not quite the best place for it. Anyway, on to the problem.

I have seen that data coming from Kendo POST and PUT operations is formatted.. uh.. really strangely. Tastypie (which is an API framework) barfs up an error like so:

raise ValueError("No JSON object could be decoded")

So I inserted some code into my back-end to dump the raw data. You can see a sample of that data here:

active=false&description=Small+shiny+Widget&internal_part_no=A01-1&low_stock_alert=10&manuf_part_no=83927&pub_date=2012-10-03T19%3A48%3A19.559618&quantity_available=1&serial_no=00001&title=Special+part+01&unit_cost=124.43

This differs quite a lot from the formatting when I use Ext JS to POST or PUT, you can see a sample of roughly equivalent data here:

{"id":2,"description":"Special funky widget","manuf_part_no":"9766","internal_part_no":"A02-1","serial_no":"010101","unit_cost":"22.98","added_date":""}

At this point I suspect that I must be missing something really obvious with my Kendo configuration. I have attached the javascript used to produce the sample data in this post. It's not a problem for me to write a custom deserializer for the back-end to handle this data, but I feel like I must be making a simple mistake. Thanks for any ideas.

2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 15 Oct 2012, 07:43 AM
Hello Wes,

 By default the Kendo DataSource submits data in application/x-www-form-urlencoded format which of course cannot be parsed as JSON. This behavior is inherited from jQuery.ajax which is used behind the curtains.

 To send the DataSource parameters in JSON format you should use the parameterMap function:

parameterMap: function(options, type) {
     return JSON.stringify(options);
}

Greetings,
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
Wes
Top achievements
Rank 1
answered on 15 Oct 2012, 09:02 PM
Thank you Atanas, I can confirm that does produce JSON output.
Tags
Grid
Asked by
Wes
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Wes
Top achievements
Rank 1
Share this question
or