Open or close a section in the tree timeline

I need to open or close a section in the timeline depending on if there are any events in the section or not. So if there are no events visible, the section should be closed and if there are events in the section should be opened.

I know about the methods scheduler.openSection and scheduler.closeSection but I don’t know which scheduler events I can use to handle this. Every time the scheduler is updated, i.e. events loaded from store or the view is updated I would like to make this check. The problem is if I add this check to onViewChange and close a section using closeSection, the onViewChange event is triggered again, sending my code into a indefinite loop.

Any suggestions are welcome

Hi,
you can catch events that indicates change of data in the scheduler

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

You can open or close sections directly from the data, by accessing section object and setting the value of a ‘open’ property. In order to apply the changes you’ll need to redraw the scheduler using scheduler.setCurrentView()

Thanks for your reply. Unfortunately this doesn’t help me.,

The problem is this:

I load data from the datasource, then the onXLE is triggered. Now I can use this to open or close a section if there are events in a given section. Lets say for week 1 there are no events, so the section closes.

Then I go to the next week, the onXLE is triggered and there are events in the section that was closed earlier. Now the section opens.

Then I go back to the previous week. Since the data for that week alread is loaded, the onXLE is never fired. Thus the section remains open even though there are no data in it.

I really don’t want to redraw the scheduler each time I “browse” to a week that is already loaded.

Hi,
try using onBeforeViewChange event for such cases.
It triggers before the view is scrolled, the dates to be shown are known there
docs.dhtmlx.com/scheduler/api__s … event.html