Add sections and events on the fly in timeline view

Hi,

I’m having some problem trying to add sections and events on the fly in the timeline view (not in tree mode).
I was first using addSection() and addEvent() but i read in the doc that this is reserved for timeline in treeview mode so i 'm trying to use the updateCollection. and this is working fine with the sections.

scheduler.createTimelineView({
       ...
        y_unit: scheduler.serverList("elemJour", listeUsers),
        ...
    });

then in a function i’m calling

scheduler.updateCollection("elemJour", updatedListeUsers);

And the section is added
My events are loading as followed in the init() function

scheduler.parse(JSON.stringify(scheduler.serverList("events", listeEvents)), "json");

then right after inserting my section i’m trying to add the related events
I get them from an ajax call then i add the returned events to my global list and then i update the collection but nothing happend my section (just added above) remain still empty.

$.getJSON(urlGetUserEvent , function (datauserevent) { 
                
                // add new events to the main list
                listeEvents = listeEvents.concat(datauserevent);
                
                // update events collection
                scheduler.updateCollection("events", listeEvents);
                
                // close modale   
                $('#addUserForm').modal('hide'); 
            });  

I’m sure i’m missing something :slight_smile:

Doesn’t seem to work this way but the scheduler.addEvent(ev); is working fine in a loop.

$.getJSON(urlGetUserEvent , function (datauserevent) { 
                
                $.each(datauserevent, function(i,vi){
                    scheduler.addEvent(vi);
                });
                
                // close modal   
                $('#addUserForm').modal('hide'); 
            }); 

thanks

hi,
you can use scheduler.parse for adding multiple events:
docs.dhtmlx.com/scheduler/api__s … parse.html

Wow nice ! Thanks a lot!
You saved me from tons of loops in my code! :smiley: