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

How to post data using parameterMap in kendo scheduler

5 Answers 421 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jsn
Top achievements
Rank 1
Jsn asked on 13 Sep 2013, 09:36 AM
Hi,

I just want to know how to post data using the parameterMap function in kendo scheduler, as what I understand the default type is "Get", for some reason I need to do a "Post" type, It seems that my code (see sample code below) does not work, and when I look into the posted data the result is always something like this ( f=%22somedata%22 ) Is there something  wrong in my code? 

dataSource: {
  transport: {
       read: {
      type: "POST",
      url: "myurl",
      dataType: "json",
      contentType: "application/json; charset=utf-8"
 
       },
       parameterMap: function (options, operation) {
                                           
         return { f: JSON.stringify("somedata") };
         }
       },
        schema:
               {
                   //some code here....
               }
 }
I also try the code below as what I see in this link http://jsfiddle.net/Xhrrj/4/.. but it seems not working to me.. the result of the posted data is something like this ( f= somedata )...
parameterMap: function (options, operation) {
                                                                                    $.extend({}, options, { f: "somedata" })
                                        }

 
Thanks,

Regards, 
Jesson

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 13 Sep 2013, 10:02 AM
Hi Jesson,

 The parameterMap function expects a result to be returned. Try modifying your code like this:

parameterMap: function (options, operation) {
   return $.extend({}, options, { f: "somedata" });
}

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jsn
Top achievements
Rank 1
answered on 13 Sep 2013, 10:11 AM
Hello Atanas Korchev,

parameterMap: function (options, operation) {
 
         return $.extend({}, options, { f: "somedata" })
                                        }
I already try the above code, but when I check the the result, what I get is always the source of the POST something like this " f = somedata ", it seems that type:"POST" is not working in my code.. I expect that I will see the POST Parameter  something like " f    somedata  " without the '=' sign.

Regards,
Jesson
0
Atanas Korchev
Telerik team
answered on 13 Sep 2013, 10:14 AM
Hello Jesson,

I believe this is how the browser shows POST requests. You can check that with a regular $.ajax call.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jsn
Top achievements
Rank 1
answered on 13 Sep 2013, 12:29 PM
Hello Atanas Korchev,

I try the regular $.ajax call , the browser "POST" displayed both the POST source and the POST parameter which is

Parameter
   f   somedate

Source
  f=somedata

But when I try to use the parameterMap function in kendo scheduler, browser only display the Source of the post, which is 

Source
  f=somedata

By the way I'm using the trial version  2013.2.716 of Kendo UI..


Regards,
Jesson  
0
Accepted
Jsn
Top achievements
Rank 1
answered on 13 Sep 2013, 12:58 PM
Hi,

Okay, I got it to work the POST method using parameterMap function in kendo scheduler by removing the --> contentType: "application/json; charset=utf-8"
Here's my code snippet for that :
dataSource: {
                    transport: {
                                          read: {
      type: "POST",
      url: "myurl",
      dataType: "json"
     },
      parameterMap: function (options, operation) {
                                             
                return $.extend({}, options, { f: "somedata" })
                                             
     }
  }
}
When I remove the  "contentType" option inside "read", the post method works.

Thanks Atanas Korchev for your replies.

Regards,
Jesson
Tags
Scheduler
Asked by
Jsn
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Jsn
Top achievements
Rank 1
Share this question
or