I have a project that should be very simple that uses one of the demos as a template, yet it is not loading data from the server - I am sure I am missing something simple, if anyone can help identify?
Things of note:
* If I give it a datasource manually, items appear, so I guess the events for "transport -> read" are not being triggered?
*If I put in a navigate option (navigate: scheduler_navigate), this gets called, and I see JSON data returned from the server - however, my understanding is this should not be necessary as "transport -> read" takes care of polling data from the server/data-source?
thanks.
Allen.
(1) The JS
// scheduler setup
scheduler = $("#scheduler").kendoScheduler({
views: ["day", { type: "workWeek" }, "week", "month", "agenda", { type: "timeline", eventHeight: 30, selected: true }],
timezone: "Etc/UTC",
majorTick: 30,
datasource: {
batch: true,
transport: {
read: {
url: "/Home/LoadTasks",
datatype: "jsonp"
},
update: {
url: "/home/update",
datatype: "jsonp"
},
create: {
url: "/home/create",
datatype: "jsonp"
},
destroy: {
url: "/home/destroy",
datatype: "jsonp"
},
parametermap: function (options, operation) {
if (operation !== "read" && options.models) {
return { models: kendo.stringify(options.models) };
}
if (operation == "read") {
var scheduler = $("#scheduler").data("kendoscheduler");
return {
type: "workweek",
start: kendo.tostring(new date(scheduler.view().startdate()), "u"),
end: kendo.tostring(new date(scheduler.view().enddate()), "u")
}
}
}
}
},
schema: {
model: {
id: "taskId",
fields: {
taskId: { from: "TaskID", type: "number" },
title: { from: "Title", defaultValue: "No title", validation: { required: true } },
start: { type: "date", from: "Start" },
end: { type: "date", from: "End" },
startTimezone: { from: "StartTimezone" },
endTimezone: { from: "EndTimezone" },
description: { from: "Description" },
recurrenceId: { from: "RecurrenceID" },
recurrenceRule: { from: "RecurrenceRule" },
recurrenceException: { from: "RecurrenceException" },
isAllDay: { type: "boolean", from: "IsAllDay" }
}
}
// }
},
resources: resourceArray,
group: {
resources: ["branches", "users"],
orientation: "vertical"
},
startTime: new Date("2013/6/13 07:00 AM"),
height: 600
}
)
(2) Controller
public JsonResult LoadTasks(string type, string start, string end)
{
TaskRepository TaskRep = new TaskRepository();
return this.Jsonp(TaskRep.dateRange(type, start, end));
}
(3) VM / Repo
public IList<SchedulerEvent> dateRange(string type, string startDate, string endDate)
{
List<SchedulerEvent> result = new List<SchedulerEvent>();
DateTime dateStart = Convert.ToDateTime(startDate);
DateTime dateEnd;
if (endDate != "")
{
dateEnd = Convert.ToDateTime(endDate);
}
if (result == null || UpdateDatabase)
{
if (type == "workWeek")
{
dateEnd = dateStart.AddDays(4);
SchedulerEvent itm1 = new SchedulerEvent();
itm1.TaskID = 1;
itm1.Title = "Task 1";
itm1.Start = DateTime.SpecifyKind(dateStart, DateTimeKind.Utc);
itm1.End = DateTime.SpecifyKind(dateEnd, DateTimeKind.Utc);
itm1.StartTimezone = null;
itm1.EndTimezone = null;
itm1.Description = "Description";
itm1.IsAllDay = false;
itm1.RecurrenceRule = null;
itm1.RecurrenceException = null;
itm1.branchID = 10;
itm1.userID = 1;
result.Add(itm1);
SchedulerEvent itm2 = new SchedulerEvent();
itm2.TaskID = 1;
itm2.Title = "Task 2";
itm2.Start = DateTime.SpecifyKind(dateStart.AddDays(1).AddMinutes(30), DateTimeKind.Utc);
itm2.End = DateTime.SpecifyKind(dateEnd.AddDays(1).AddMinutes(30), DateTimeKind.Utc);
itm2.StartTimezone = null;
itm2.EndTimezone = null;
itm2.Description = "Description";
itm2.IsAllDay = false;
itm2.RecurrenceRule = null;
itm2.RecurrenceException = null;
itm2.branchID = 20;
itm2.userID = 2;
result.Add(itm2);
SchedulerEvent itm3 = new SchedulerEvent();
itm3.TaskID = 1;
itm3.Title = "Task 3";
itm3.Start = DateTime.SpecifyKind(dateStart.AddDays(2).AddMinutes(45), DateTimeKind.Utc);
itm3.End = DateTime.SpecifyKind(dateEnd.AddDays(2).AddMinutes(45), DateTimeKind.Utc);
itm3.StartTimezone = null;
itm3.EndTimezone = null;
itm3.Description = "Description";
itm3.IsAllDay = false;
itm3.RecurrenceRule = null;
itm3.RecurrenceException = null;
itm3.branchID = 10;
itm3.userID = 3;
result.Add(itm3);
}
else if (type == "timeline" || type == "day")
{
dateEnd = dateStart.AddDays(1);
SchedulerEvent itm1 = new SchedulerEvent();
itm1.TaskID = 1;
itm1.Title = "Task 1";
itm1.Start = DateTime.SpecifyKind(dateStart, DateTimeKind.Utc);
itm1.End = DateTime.SpecifyKind(dateEnd, DateTimeKind.Utc);
itm1.StartTimezone = null;
itm1.EndTimezone = null;
itm1.Description = "Description";
itm1.IsAllDay = false;
itm1.RecurrenceRule = null;
itm1.RecurrenceException = null;
itm1.branchID = 10;
itm1.userID = 1;
result.Add(itm1);
SchedulerEvent itm2 = new SchedulerEvent();
itm2.TaskID = 1;
itm2.Title = "Task 2";
itm2.Start = DateTime.SpecifyKind(dateStart.AddMinutes(30), DateTimeKind.Utc);
itm2.End = DateTime.SpecifyKind(dateEnd.AddMinutes(30), DateTimeKind.Utc);
itm2.StartTimezone = null;
itm2.EndTimezone = null;
itm2.Description = "Description";
itm2.IsAllDay = false;
itm2.RecurrenceRule = null;
itm2.RecurrenceException = null;
itm2.branchID = 20;
itm2.userID = 2;
result.Add(itm2);
SchedulerEvent itm3 = new SchedulerEvent();
itm3.TaskID = 1;
itm3.Title = "Task 3";
itm3.Start = DateTime.SpecifyKind(dateStart.AddMinutes(45), DateTimeKind.Utc);
itm3.End = DateTime.SpecifyKind(dateEnd.AddMinutes(45), DateTimeKind.Utc);
itm3.StartTimezone = null;
itm3.EndTimezone = null;
itm3.Description = "Description";
itm3.IsAllDay = false;
itm3.RecurrenceRule = null;
itm3.RecurrenceException = null;
itm3.branchID = 10;
itm3.userID = 3;
result.Add(itm3);
}
}
HttpContext.Current.Session["Tasks"] = result;
return result;
}