Search code examples
kendo-uikendo-scheduler

Kendo Scheduler events disappear after cancelling edit


I've setup a Kendo Scheduler widget using Kendo Web GPL version 2013.3.1119.

It's mostly working fine, in that events are pulled from the remote SchedulerDataSource and correctly displayed on the calendar with their associated resource.

The problem is ... when I double-click an event the popup editor is displayed containing the correct data, but if I click Cancel or the close 'X', the event is removed from the calendar.

There are no errors, the event just disappears.

Any ideas what may be causing this?


Solution

  • I think I've found the problem. The configuration of the SchedulerDataSource is slightly counter-intuitive.

    My database stores the ID of events as id but the Scheduler requires taskId, so in the schema that field is defined like:

    taskId: { from: 'id', type: 'number' }
    

    but I didn't realise you also had to define the model id as taskId rather than what's actually returned by the server.

    So the complete SchedulerDataSource schema looks like:

    schema: {
                data: 'data',
                total: 'total',
                model: {
                    id: 'taskId',
                    fields: {
                        taskId: { from: 'id', type: 'number' },
                        title: { from: 'title', defaultValue: 'No title', validation: { required: true } },
                        start: { type: 'date', from: 'start' },
                        end: { type: 'date', from: 'end' },
                        description: { from: 'description' },
                        ownerId: { from: 'employee_id' },
                        isAllDay: { type: 'boolean', from: "allDay" },
                        type_id: { type: 'number' }
                    }
                }
            }
    

    Just out of interest, does anybody know you can define field 'aliases' using from: 'server-field' in a regular Kendo DataSource? Could be useful.