Load sections dynamically

Hello,

I’m using version 2.3 of the library and the server side programming is in Java. I would like to load scheduler sections (for unit view) dynamically. The idea is not only to retrieve these sections at application startup, but also to be able to reload completely new sections aferwoods. Until now, I haven’t found any way to delete unit views and properly refresh the scheduler. Thanks for any help.

Regards,

Loïc

Hello, Loïc.

It’s possible to update list of resources. I’ve attached sample which illustrates it. Main logic there:

sections.splice(0,sections.length); // clearing the array which was used to specify list of sections to be displayed sections.push.apply(sections,sect); // pushing in the same array new list of options from the array 'sect' scheduler.callEvent("onOptionsLoad",[]); // event to update list of options scheduler.setCurrentView(scheduler.getState().date, scheduler.getState().mode); // refreshing current view

In the upcoming version this functionality will be improved and you will be able to simply write scheduler.updateCollection(“units”, new_array_to_display);
If you want you can try to use our latest development version which I attached to another topic.

Also you can add scroll to the units view, check Units scrolling section on the docs.dhtmlx.com/doku.php?id=dhtm … units_view page.

Best regards,
Ilya
13_modify_units_view.zip (1.32 KB)

Hello,

Thanks for your quick answer. The provided code works perfectly. However, I still have an issue I need to solve : not only that I have to load sections dynamically, but also units. I would need to be able to delete and recreate units dynamically. Is there a way to achieve this without modifying/overriding the library ?

Best regards,

Loïc

Hello,

And what is the difference? Or you mean you want to update sections (units, resources) not only units view but timeline too?

Best regards,
Ilya

Hello,

A call to “createUnitsView” adds a tab in the scheduler. I would need to have the possibility to add and remove units tabs dynamically. I hope I’m more clear.

Best regards,

Loïc

Scheduler is not purposed for such use-case.
While it possible to add new units view, there is no way to remove the one, which is already created.

Can you describe the use-case where you need to create units view dynamically?

Hello,

I have a combo box which displays several calendars (for distinct entities). The connected user has write access on “his” calendar but also has the possibility to switch between these entities and consult their calendars. Entities may have completely different calendars from one another. That’s why I have to gain the ability to remove units tab.

To achieve such functionnality, I guess I’ll have to override the “createUnitsView” method so that I can save a reference to the “onOptionLoad” event handler. Thus, I will have the possibility to detach the event handler whenever I need to remove a units view from the “scheduler._props” list.

Best regards,

Loïc

I guess I’ll have to override the “createUnitsView” method
Yep it may improve the situation

But beware that during unit view creation, there are some other inner events attached, so each new unit view will add complexity to the inner logic, if you will continue to add units view, at some point it may slow down rendering and reaction times.

Thanks - the code above (with the current version) was just what I needed and very timely.