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
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
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.
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?
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