Dynamic data loading and the resource view

I’ve got a quite complicated system to calculate the resource load, which does not allow me to have all the info in memory at once. So what I would like to do is, as I switch to a more fine grained view (month -> day) to dynamically load the newly needed data.

I can kick off the AJAX request when I press the button to toggle the view mode. However the view mode is fully changed before my AJAX request completes and thus when the resource diagramm is drawn and my resource_cell_{class|value} get called I do not have the data ready.

Is there a way to either:

  • delay the drawing until a condition is met (maybe show a nice spinner instead) or
  • force the gantt to repaint the resource diagramm?

Hello,
There is “onBeforeDataRender” event, but unfortunately it doesn’t depend on returning values (like some other functions allow canceling the event).
But before rendering you can show an overlay and a nice spinner. Then you use a delayed function that will always check the condition. Here is an example how it might be implemented:
snippet.dhtmlx.com/189b720ec

To repaint the whole chart you can try “gantt.render()” function or even gantt.init() function if there is something related to templates or something else.