I’m using a JSF query (via a4j:jsFunction) to get scheduling data (fired via onBeforeViewChange event). When the jsFunction returns I have the data in an array of objects that are the same structure as events. I was loading the data with:
for (var i = 0; i < events.length; i++) {
scheduler.addEvent(events[i]);
}
However, when I started to approach 1000 events in a month, the load was taking on the order of 30 seconds in Chrome and pretty much killed IE9. So after digging into the source I tried the following and it worked really well. The time when from 30 seconds to under 1 second.
scheduler._loading = true;
scheduler._not_render = true;
for (var i = 0; i < events.length; i++) {
scheduler.addEvent(events[i]);
}
scheduler._loading = false;
scheduler._not_render = false;
scheduler.render_view_data();
So my question, is this the right want to handle this? Am I missing anything? If there isn’t a way to bulk load from an array, may I suggest adding one.
Note: I’m very new to Javascript and DHTMLX so it’s quite possible I’m missing something big here.
scheduler.parse(events, “json”); doesn’t work for me. I think the issue is that the data has already been parsed into objects. I believe the scheduler.parse function is expecting date strings that it then parses into date objects but in my events, the start and end dates are already Date objects.
I understand this is using internal hooks and I’m hoping that you might consider adding a new API point where the user can pass already parsed events to be loaded. In my case using a4j:jsFunction, the return data structure from JSF gets unmarshalled automatically into objects, including date parsing.
Thanks for the reply, it at least confirmed that I wasn’t just missing something. I hope you will consider adding a new entry point to the API, but if not I can probably live with that risk that I might have to make changes with any new versions.
I tried your suggestion of changing the xml_date template, and it does work for loading the data. However, it breaks the minical extension. I get the following error:
Uncaught TypeError: Object 04/01/2013 00:00 has no method 'setDate'