Hello Stanislav,
First great job
I have a list of items (custom field - select list) and I have to prevent events overlapping according to each item of the list (if I have 7 items then at the same time I can have a maximum of 7 rendez-vous).
So to do the job, what do you think about adding this function (with another name) into dhtmlxscheduler.js ? I think that it could be interesting for other people (and maintenance is in your hands ).
scheduler.getEventsToCheckConflict = function(id,start,end){
var result = [];
for (var a in this._events){
var ev = this._events[a];
if (ev && (ev.id != id) && ((ev.start_date<=start && ev.end_date>=start)
|| (ev.start_date<=end && ev.end_date>=end)
|| (ev.start_date>=start && ev.end_date<=end)))
result.push(ev);
}
return result;
};
I use it into scheduler_include.html that way (ev.text is the key of a select - an element of a list of items):
scheduler.attachEvent("onEventSave",function(id, ev, is_new_event){
var evs = scheduler.getEventsToCheckConflict(id, ev.start_date, ev.end_date);
evs.sort(function(a,b){ return (a.start_date > b.start_date ? 1 : -1); });
for (var i=0; i<evs.length; i++) {
if(evs[i].text == ev.text) {
// It's the same item -> don't save.
return false;
}
}
return true;
})
Thanks
JMi