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
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
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;
}
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
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
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