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

Scheduler CRUD ops all want to use 'GET' type

6 Answers 121 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 26 Aug 2016, 02:33 PM

I'm having an issue with an instance of the kendoScheduler. What's going on is, all crud operations, in addition to read, seem to want to use the 'get' type. I'm using the code from the demo on this site. So I figured, OK, I'll just add in the type: 'put', say for for update method. Still doesn't work.

On the other side of things, I'm using web api and I have all my different actions in the controllers, say, we're dealing with the update one only here - I have the [httpPut] attribute on top of the action. And I'm getting the 405 method not allowed error. 

Playing around, on the client side of things, I changed the updates type, to get, and add [httpGet] to the controller (even though this clearly isn't what I want here) - when I debug this, it finds the respective action, but the model is null.

What's going on when I have httpput on the controller and why on the front end is all crud operations trying to use a get?

Thanks.

 

6 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 29 Aug 2016, 07:29 PM
*bump*
0
Georgi Krustev
Telerik team
answered on 30 Aug 2016, 08:11 AM
Hello Michael,

The guaranteed response time for forum threads is 48 hours (Mon-Fri). The record of this thread shows that the response time is in the promised range.

With regards to the question, the DataSource component (used by the Scheduler), will request the data using GET action by default. If you would like to modify that behavior, then just set the transport.[method].type value:

Based on the given details, it seems that you have already changed those properties, but I am afraid that it is not clear what exactly happens. Probably, you will need to modify the format of the send models in order to receive them on the server:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-transport.parameterMap

If the problem still persists, please send us a simplified repro demo, which we can debug locally.

Regards,
Georgi Krustev
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Michael
Top achievements
Rank 1
answered on 30 Aug 2016, 12:44 PM

I sincerely apologize about the response time.

Let me show you some code...

Here's the front end.

01.<div id="calEventSchedule"></div>
02. 
03.            <script>
04.            $(function() {
05.                $("#calEventSchedule").kendoScheduler({
06.                    date: new Date("2016/8/25"),
07.                    startTime: new Date("2016/8/25 07:00 AM"),
08.                    height: 600,
09.                    views: [
10.                        "day",
11.                        "week",
12.                        { type: "month", selected: true }
13.                    ],
14.                    timezone: "Etc/UTC",
15.                    dataSource: {
16.                        batch: true,
17.                        transport: {
18.                            read: {
19.                                url: baseURL + "api/events",
20.                                dataType: "jsonp",
21.                                type: "GET",
22.                                contentType: 'application/json; charset=utf-8'
23.                            },
24.                            update: {
25.                                url: baseURL + "Events/EventUpdate",
26.                                dataType: "jsonp",
27.                                type: "PUT",
28.                                contentType: 'application/json; charset=utf-8'
29.                            },
30.                            create: {
31.                                url: baseURL + "Events/InsertEvent",
32.                                dataType: "jsonp",
33.                                type: "POST",
34.                                contentType: 'application/json; charset=utf-8'
35.                            },
36.                            destroy: {
37.                                url: baseURL + "Events/DeleteEvent",
38.                                dataType: "jsonp",
39.                                type: "DELETE",
40.                                contentType: 'application/json; charset=utf-8'
41.                            },
42.                            parameterMap: function(options, operation) {
43.                                if (operation !== "read" && options.models) {
44.                                    return {models: kendo.stringify(options.models)};
45.                                }
46.                            }
47.                        },
48.                        schema: {
49.                            model: {
50.                                id: "taskId",
51.                                fields: {
52.                                    taskId: { from: "taskId", type: "number" },
53.                                    title: { from: "title", defaultValue: "No title", validation: { required: true } },
54.                                    start: { type: "date", from: "start" },
55.                                    end: { type: "date", from: "end" },
56.                                    startTimezone: { from: "startTimezone" },
57.                                    endTimezone: { from: "endTimezone" },
58.                                    description: { from: "description" },
59.                                    recurrenceRule: { from: "recurrenceRule" },
60.                                    isAllDay: { type: "boolean", from: "isAllday" }
61.                                }
62.                            }
63.                        }
64.                    }
65.                });
66. 
67.            });
68.            </script>

And and example of the PUT action in the web api controller...

        // PUT: edit a event
        [HttpPut]
        [Route("Events/EventUpdate")]
        public Int16 EventUpdate([FromBody]vw_Events_GetAll model)
        {

            Int16 eventresult = 0;

            string _title = model.title;
            DateTime _start = (DateTime)model.start;
            DateTime _end = (DateTime)model.end;
            string _startTimezone = model.startTimezone;
            string _endTimezone = model.endTimezone;
            string _description = model.description;
            string _recurrenceRule = model.recurrenceRule;
            Boolean _isAllday = (Boolean)model.isAllday;
            Int32 _taskId = model.taskId;

            try
            {
                var result = db.spEventsUpdate(_title, _start, _end, _startTimezone, _endTimezone, _description, _recurrenceRule, _isAllday, _taskId);
                db.SaveChangesAsync();

                foreach (var key in result)
                {
                    eventresult = Convert.ToInt16(key.taskId);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e);
                //really should write to db
            }

            return eventresult;

        }

0
Georgi Krustev
Telerik team
answered on 01 Sep 2016, 07:37 AM
Hello Michael,

JSONP supports only GET method. If you need to use PUT, POST and etc, then you will need to switch to JSON data type. The easiest solution is to use proxy server.

You can check this extensive StackOverflow answer devoted on the same subject:

http://stackoverflow.com/a/5345681/324224

Regards,
Georgi Krustev
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Fevzi
Top achievements
Rank 1
answered on 18 Mar 2019, 06:47 AM

Hi,

public Int16 EventUpdate([FromBody]vw_Events_GetAll model)

In the method header you use a model type of ww_Events_GetAll. How on earth, the method can understand what that is. Whre is it defined? I fit is a type defined corresponding to the Event properties, it does not work.

Could you please clarify?

Regards,

Frank

 

0
Joana
Telerik team
answered on 19 Mar 2019, 12:56 PM
Hi Fevzi,

The type of result is retrieved by the dataType dataSource configuration option. You could find more information in the following link:

https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/transport.read#transportreaddatatype

Regards,
Joana
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Scheduler
Asked by
Michael
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Georgi Krustev
Telerik team
Fevzi
Top achievements
Rank 1
Joana
Telerik team
Share this question
or