Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 722
Mat Avatar asked Jan 24 '14 14:01

Mat


2 Answers

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.

like image 169
Mat Avatar answered Sep 24 '22 02:09

Mat


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);
      }
    )
  )
)
like image 33
Vitalii Bratok Avatar answered Sep 24 '22 02:09

Vitalii Bratok