DHTMLX / scheduler

GPL version of JavaScript Event Scheduler
https://dhtmlx.com/docs/products/dhtmlxScheduler/
GNU General Public License v2.0
319 stars 111 forks source link

JavaScript: Add Recurring Events #38

Closed AllanCodes closed 6 years ago

AllanCodes commented 6 years ago

I'd like to add this event to my calendar

let eventID = scheduler.addEvent({
                        start_date: "2018-03-03 10:00:00",
                        end_date: "2018-03-10 11:00:00",
                        text: "words",
                        details: "",
                        rec_type: "week_1___1,2",
                    });

However, when I run through that part of my code I get an error in dhtmlxscheduler.js Cannot read property 'valueOf' of undefined. What's the proper way to add an event as recurring. I've added the dependency js file for recurring events and specified the following in my init

    scheduler.config.details_on_create=true;
    scheduler.config.details_on_dblclick=true;
    scheduler.config.include_end_by = true;
    scheduler.config.repeat_precise = true;        
    var today = new Date(); 
    scheduler.init('scheduler_here',today, "week"); 
AlexKlimenkov commented 6 years ago

Hi, you'll need a bit different values for recurring event Firstly, when you add events using scheduler.addEvent, start and end dates should have Date type The end_date property defines the end date of the whole series (i.e. repeat from 2018-01-01 to 2019-01-01), event duration should be set in event_length property. A following should work as expected:

scheduler.addEvent({
     start_date: new Date(2018, 2, 3, 10, 0),//start_date of Date type
     end_date: new Date(2019, 2, 3, 10, 0),//also Date type, end date of the whole series
     text: "words",
     details: "",
     rec_type: "week_1___1,2",
     event_pid: 0,//parent series id, not default only for modified occurrences
     event_length: 3600//duration of a single event, in seconds
});