This is a migrated thread and some comments may be shown as answers.

event edit preventDefault removes event.

5 Answers 413 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Aksel
Top achievements
Rank 1
Aksel asked on 09 Oct 2015, 11:08 AM

Hello

I'm trying to use the scheduler with a custom event editor that has already been written. I want to open that when the edit event is triggered, but if call preventDefault on it, the event disappears from the scheduler. How can I prevent this from happening?

5 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 13 Oct 2015, 08:57 AM
Hi Aksel,

From the provided information it seems that the scheduler dataSource "schema.model.id" option is not set or the events have no valid unique ID. Could you please make sure this option is set to the correct field that contains the events IDs and let us know of the result?

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Aksel
Top achievements
Rank 1
answered on 13 Oct 2015, 10:27 AM

The schema.model.id field has been set:

01.$scope.ds = new kendo.data.SchedulerDataSource({
02.         data: eventList,
03.         model: {
04.             id: "id",
05.             fields: {
06.                 id:{from:"id", type:"number"},
07.                 start: { type: "date", from: "start" },
08.                 end: { type: "date", from: "end" },
09.                 title: { from: "title", defaultValue: "-" }
11.             }
12.         }
13.     });

and every event gets an unique ID.

I can replicate it happening using this Dojo thing:

http://dojo.telerik.com/egapu

If you run it using Kendo UI 2015 Q3 it works properly, so I assume it has been fixed. When using Q2 the event just disappears when double clicking it.

0
Aksel
Top achievements
Rank 1
answered on 13 Oct 2015, 12:47 PM

The schema.model.id field has been set:

var ​eventList = new kendo.data.ObservableArray([]);
var dataSource = new kendo.data.SchedulerDataSource({
           data:eventList,
           schema: {
               model: {
                   id: "BookingOccasionId"
               }
           }
       });

and every event gets an unique ID.
I can replicate it happening using this Dojo thing:
http://dojo.telerik.com/inESe/3

Press update to add an event. then double click that. the event disappears. Have I done something incorrectly? 

1
Accepted
Vladimir Iliev
Telerik team
answered on 14 Oct 2015, 11:50 AM
Hi Aksel,

The reason for current behavior is that when you directly push the event to the observable collection it's never added to the internal "pristine" collection of the dataSource which is used to hold the original state of the data. When you prevent the "edit" event, the "cancelChanges" method of the dataSource is called which restores the data from that "pristine" collection which is still empty. That why for inserting new events in current scenario I would suggest to still use the dataSource API:

var scheduler = $("#scheduler").kendoScheduler({
    dataSource: dataSource,
    date: new Date("2013/6/13"),
    startTime: new Date("2013/6/13 07:00 AM"),
    height: 600,
    views: [
        "day"
    ],
    edit: function(e) {
        e.preventDefault();
        console.log(e.event);
    },
 
}).data("kendoScheduler");
 
 
 
$("#addEvents").click(function(e) {
    scheduler.dataSource.pushCreate(booking);
});

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Aksel
Top achievements
Rank 1
answered on 14 Oct 2015, 12:33 PM
Ah, that did the trick! Thank you for your help!
Tags
Scheduler
Asked by
Aksel
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Aksel
Top achievements
Rank 1
Share this question
or