I have a scheduler where I'd like to display more calendars.
In my situation I have to load the empty scheduler and then populate it dinamically.
For simulate it, I have two methods in the main function: "scheduler_show" that display the scheduler without data and "schduler_update" that load data on it.
I don't know why, but it loads correctly all the calendars and items, but doesn't show the right colour of the tasks (also if they're associated with the right resource).
Where I'm wrong?
This is the script:
In my situation I have to load the empty scheduler and then populate it dinamically.
For simulate it, I have two methods in the main function: "scheduler_show" that display the scheduler without data and "schduler_update" that load data on it.
I don't know why, but it loads correctly all the calendars and items, but doesn't show the right colour of the tasks (also if they're associated with the right resource).
Where I'm wrong?
This is the script:
$(function() { scheduler_show(); scheduler_update();});var schedulerTasks = [];var schedulerDataSource = new kendo.data.SchedulerDataSource({ transport: { read: function (request) { request.success(schedulerTasks); }, parameterMap: function (options, operation) { if (operation !== "read" && options.models) { return { models: kendo.stringify(options.models) }; } } }, schema: { model: { id: "taskId", fields: { taskId: { from: "Id" }, title: { from: "Title", validation: { required: true } }, start: { type: "date", from: "StartDate" }, end: { type: "date", from: "EndDate" }, description: { from: "Description" }, calendarId: { from: "CalendarId", validation: { required: true } }, isAllDay: { type: "boolean", from: "IsAllDay" } } } }, filter: { logic: "or", filters: [] }});function scheduler_show() { kendo.culture("it-IT"); $("#scheduler").kendoScheduler({ date: new Date("2014/03/19"), startTime: new Date("2014/03/19 01:00 AM"), height: $(document).height() - 20, views: [ { type: "day", dateHeaderTemplate: kendo.template("<strong>#=kendo.toString(date, 'ddd dd')#</strong>")}, { type: "workWeek", selected: true, dateHeaderTemplate: kendo.template("<strong>#=kendo.toString(date, 'ddd dd')#</strong>") }, { type: "week", dateHeaderTemplate: kendo.template("<strong>#=kendo.toString(date, 'ddd dd')#</strong>")}, "month", "agenda" ], save: scheduler_save, remove: scheduler_remove, timezone: "Etc/UTC", dataSource: schedulerDataSource, resources: [ { field: "calendarId", title: "Calendario", dataSource: [] } ] });}function scheduler_update(){ var calendarResources = [ { "text": "Calendar ONE", "value": "mycalendar1", "color": "#9fc6e7" },{ "text": "Calendar TWO", "value": "mycalendar2", "color": "#7bd148" }]; var calendarFilters = [ { "field": "calendarId", "operator": "eq", "value": "mycalendar1" },{ "field": "calendarId", "operator": "eq", "value": "mycalendar2" }]; schedulerTasks = [{"Id": "task1","Title": "Task 1","Description": null,"CalendarId": "mycalendar1","StartDate": "2014-03-19 08:00","EndDate": "2014-03-19 09:00","IsAllDay": false}, {"Id": "task2","Title": "Task 2","Description": null,"CalendarId": "mycalendar2","StartDate": "2014-03-19 10:00","EndDate": "2014-03-19 11:00","IsAllDay": false}]; var schedulerControl = $("#scheduler").data("kendoScheduler"); schedulerControl.resources[0].dataSource.data(calendarResources); schedulerControl.resources[0].dataSource.filter(calendarFilters); schedulerDataSource.read(); schedulerControl.view(schedulerControl.view().name);}function scheduler_save(options) {}function scheduler_remove(options) {}