8

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?

Mat
  • 1,608
  • 3
  • 22
  • 37

3 Answers3

14

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.

Mat
  • 1,608
  • 3
  • 22
  • 37
  • This fixed the problem for me as well, thanks for posting your solution. – Scott Oct 12 '14 at 21:09
  • 2
    I don't see what difference using the string "taskId" makes. I did find some more information here : http://www.telerik.com/forums/bug---cancel-button-in-event-edit-window-is-removing-event – Patrick J Collins Feb 11 '15 at 14:55
  • Thanks very much for posting this. Probably saved me a tonne of time. – Chris Mar 29 '16 at 09:20
2

The exect issue I had. And the reason of this 'bug' was that I set up a model wrong. In my case all ids for all events were the same. So double check event ids for uniqueness.

The example for Razor syntax:

@Html.Kendo().Scheduler<EventsViewModel>()
   .Name("scheduleTimes")
   .Timezone("Etc/UTC")
   .Views(views => views.WeekView())
   .DataSource(d => d
      .Model(m =>
      {
         m.Id(f => f.TimeId); //!!! TimeID should be unique
         m.Field(f => f.Title).DefaultValue(" ");
         m.Field(f => f.Start).Editable(true);
         m.Field(f => f.End).Editable(true);
      }
    )
  )
)
Vitalii Bratok
  • 441
  • 5
  • 6
0

I too have had to update this inside Kendo Scheduler object:

 $("#schedulerID").getKendoScheduler().dataSource._pristineData

When I add a new task to scheduler, the new object is added to the end of that array "_pristineData", but it "id" field is empty. If I cancel editing...This new taks disappear in browser. Then I update Kendo Scheduler object thus:

 var length = $("schedulerID").getKendoScheduler().dataSource._pristineData.length;
 $("#schedulerID").getKendoScheduler().dataSource._pristineData[length - 1].id = id;

...and works for me.

ajcarracedo
  • 226
  • 3
  • 12