Load Timeline Events dynamically.

My timeline implementation might include the data of a whole year and I want to load the data as they are needed based on the time period selected in the scheduler timeline.

I added an event handler to the onViewChange event that calculates the dates and the data that needs to be ‘added’ to the scheduler. The data might include more sections and of course more events.

I’m using scheduler.updateCollection(“units”, sections);
to update the section of the timeline, and it works fine, al new sections are displayed in the timeline, but, in order to add the new events I have tried several approaches and none of them works.
I tried scheduler.addEvent to add the additional events.
I tried scheduler.setEvent and then scheduler.setCurrentView() and the events are not show.

I have also tried parsing again all events (already loaded and new events based on the dates) and only the additional events, with scheduler.parse and the additional events do not display.

So, what would be the correct approach to only load an incremental amount of events when the dates changes on the timeline?

I using the dhtmlxscheduler_timeline v.4.3.0 professional

Thanks in advance

did you try this method?
docs.dhtmlx.com/scheduler/api__s … dmode.html

Is there an event on the client side that fires when new data is required using this mode?

My data is on a cloud application and I’m reading the data with ODATA directly from the client side. So I would need to know when new data is needed so I can make the ODATA query to read it.

got it,
the dynamic loading triggers ‘onXLS’ event. However in your case probably it will be better to capture onBeforeViewChange and do requests from there

[code]scheduler.attachEvent(“onBeforeViewChange”, function(old_mode,old_date,mode,date){
if(old_mode == mode && +old_date == +date) return true;//do nothing on simple refresh

var min = scheduler.date[mode + “_start”](new Date(date));
var max = scheduler.date.add(min, 1, mode);

if(mode == “month”){
min = scheduler.date.week_start(min);
max = scheduler.date.add(scheduler.date.week_start(max), 1, “week”);

console.log(min, max);//here is a displayed date range

return true;
});[/code] docs.dhtmlx.com/scheduler/api__s … event.html

Aliaksandr, I already have an event to load the data, that is not the problem, I chose the onViewChange instead of onBeforeViewChange, I’m assume I can use either one of those. Or I could use onXLS as well.
But, my original problem still remains: how do I make the event data available for to the scheduler to display it ?
see my original message in this post.
scheduler.addEvent, scheduler.setEvent and scheduler.parse seem not to be working after the initial load.

ahh, sorry. I think I’ve lost it at some point
Loading events with scheduler.parse should work, there is no known problems with it.

If it’s not - maybe it’s because of a not expected format of start_date/end_date in loaded data.
Another possible reason is value of a section id property of the data items. The events won’t be displayed if they does not belong to any displayed section, you can check it by enabling display of such events, set ‘show_unassigned’ property in scheduler.createTimelineView config, all unassigned events should appear in first row

docs.dhtmlx.com/scheduler/api__s … eview.html

If none of this helps - please show a demo, so I could reproduce the issue

Thanks for all your help on this. I finally make it work with the setEvent method.

Event though I can now see the events added with setEvent, this function still has an issue. It doesn’t like the start_date the way it is parsed from an XML feed.
For the scheduler.parse method it seems like this is not a problem. In the initial load the events are shown appropriately, but, when a subsequent set of events is loaded from the same XML feed I use the setEvent and the setCurrentView methods. This is not working unless I run something like: start_date.setMinutes(60) (my start_date is always midnight). This seems to be somehow ‘fixing’ the date so the setEvent works, but now, curious thing is that even though I’m adding 60 min to the midnight, the event showa 2:00 as the time. I think this is a kind of ‘bug’.

By the way, my scheduler is a Timeline view showing just one single event each day for each section.

I got back to the schedules after a new requirements arrived for this project.
The issue with the dates (described in the previous post) is now causing some issues in the behavior of the scheduler.

Is there a way I can get some support from you guys to understand why the method:
scheduler.parse(dataRetrieved, “json”);

takes the same dates differently than the method:
scheduler.setEvent(dataRetrieved[ix].id, dataRetrieved[ix]);

I need to create a single function to handle the data because the logic form my timeline calendar is becoming more complex every day and I wouldn’t like to have different routines for data handling for each case.
Thanks in advance