Hi,
I am using angular 14 + dhlmx scheduler ^6.0.4 (node package). I am not able to create yearly events. I am receiving onEventSave instead of onEventAdded when I click on the SAVE button.
Any help would be appreciated.
Thanks,
Raj J
Hi,
I am using angular 14 + dhlmx scheduler ^6.0.4 (node package). I am not able to create yearly events. I am receiving onEventSave instead of onEventAdded when I click on the SAVE button.
Any help would be appreciated.
Thanks,
Raj J
Hi. I figured the root cause of this. when you set limit plugin as true , then it blocks you from creating
yearly events.
scheduler.plugins({
recurring: true,
editors: true,
quick_info: true,
limit: true,
collision: true // limit the count of events per time slot
});
scheduler.config.limit_view = true; // limit the possibility to view events outside the allowable date range
scheduler.config.limit_start = new Date(this.today.getFullYear(), this.today.getMonth(), this.today.getDate())
scheduler.config.limit_end = new Date(this.today.getFullYear() + 10,this.today.getMonth(), this.today.getDate());// set limits for creating events - 2 years from current date
Is this a known issue in scheduler package?
Hello @rajeswarij ,
I tried to reproduce the described issue but the creating of recurring events works correctly, here is a screencast:
https://recordit.co/n5J5i2QntI
The described issue can occur with the provided config, if you are trying to create yearly
recurring event with default start date(1st/1monday of January this year) - because scheduler can’t set the start day for this year, as it is already in the past, so event creating is blocked.
Best regards,
In that case , Can I Set the default start date dynamically while trying to create an event?
Or Is there any event I can use to detect if my event start date is past my current date ? I checked onEventSave
. But it does not trigger.
scheduler.attachEvent("onEventSave",function(id,ev){
if (!ev.name) {
scheduler.alert({
title:"Alert",
text: "Name must not be empty"
});
return false;
}
if (ev.start_date >= ev._end_date) {
scheduler.alert({
title:"Alert",
text: "Invalid end date is selected."
});
return false;
}
if (ev.start_date <= new Date() ) {
scheduler.alert({
title:"Alert",
text: "Events cannot be the created in the past date and time."
});
return false;
}
return true;
}, {id: 'save'});
Hello @rajeswarij ,
In that case , Can I Set the default start date dynamically while trying to create an event?
Yes, you can do this using the formSection
:
https://docs.dhtmlx.com/scheduler/api__scheduler_formsection.html
From the onBeforeLightbox
event:
https://docs.dhtmlx.com/scheduler/api__scheduler_onlightbox_event.html
The idea is to get the required inputs, and manually set their values accordingly to your requirements, the code may look like follows:
scheduler.attachEvent("onLightbox", function (id){
// Get curr dates
let currMonth = new Date().getMonth();
let currDay = new Date().getDate();
// Get yearly repeat pattern nodes for `every`
let recYNodeDayNumber = document.querySelector("#dhx_repeat_year").childNodes[2].childNodes[0]
let recYNodeMonthNumber = document.querySelector("#dhx_repeat_year").childNodes[3].childNodes[0]
// Set yearly repeat pattern nodes values
recYNodeDayNumber.setAttribute('value', currDay);
recYNodeMonthNumber.value = currMonth;
return true;
});
Here is a demo:
https://snippet.dhtmlx.com/j0ki79w2
Kind regards,
Hello @rajeswarij ,
Regarding this question:
Or Is there any event I can use to detect if my event start date is past my current date ? I checked onEventSave . But it does not trigger.
The provided code is almost working, but you should convert dates in checks to the timestamp format, like follows:
scheduler.attachEvent("onEventSave",function(id,ev){
if (+ev.start_date <= +new Date() ) {
scheduler.alert({
title:"Alert",
text: "Events cannot be the created in the past date and time."
});
return false;
}
return true;
}, {id: 'save'});
Here is an updated demo:
https://snippet.dhtmlx.com/gd415no4
Kind regards,
Hi,
I tweaked your code in snippet to reproduce this issue.
https://snippet.dhtmlx.com/rgrfmufd
The issue is,
I am setting limit_start as today.
Create yearly recurring event with these options in screenshot
Like you said, it should not allow me to create event because my limit_start is today and the scheduler can’t set the start day for this year, as it is already in the past, so event creating is blocked.
I agree, but on onEventSave , I am checking +ev.start_date <= +new Date(), so it should throw an error right? But instead it does not do anything.