Question

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?

Was it helpful?

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.

OTHER TIPS

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top