Hiding sections in unit view


#1

Is there any way to show only the sections with events on the display date?
For example I have this events:

 { start_date: "2015-04-20 2:20", end_date: "2015-04-20 13:00", text:"Event 1", section: 1},
 { start_date: "2015-04-21 11:40", end_date: "2015-04-21 12:20", text:"Event 2", section: 2},
 { start_date: "2015-04-23 15:00", end_date: "2015-04-23 15:40", text:"Event 3" section: 3},
 { start_date: "2015-04-24 09:00", end_date: "2015-04-24 09:40", text:"Event 4", section: 4},
 { start_date: "2015-04-21 2:20", end_date: "2015-04-20 13:00", text:"Event 5", section: 2},
 { start_date: "2015-04-21 11:40", end_date: "2015-04-21 12:20", text:"Event 6", section: 2},
 { start_date: "2015-04-23 15:00", end_date: "2015-04-23 15:40", text:"Event 7" section: 3},
 { start_date: "2015-04-24 09:00", end_date: "2015-04-24 09:40", text:"Event 8", section: 4}

If I choose the unit view for 21/04, it would show me sections 1,2,3, and 4, but the only section that has events for this day is section 2. So I would like to show only the label for section 2 and not the other sections. Kind of like optimizing the space, because it is unnecessary to show the other sections if there are no events for that day.

This is other case:

In here the section for Linda Brown doesn’t have any events but it’s still showing. I would like to show only the sections with events for that date, in this case James Smith, John Williams and David Miller.
Thanks!


Remove or Hide Section if No Children Sections
#2

Hello Javiera Meneses,
sorry for so long delay, but I could find the solution. In order to display only sections with events, please follow these general steps:
1). Every time the onViewChange fires the value of the collection of the list property should be changed according to the actual events:
https://docs.dhtmlx.com/scheduler/api__scheduler_onviewchange_event.html
2). You can take the actual events via getEvents() and change the collection via serverList and updateCollection() methods.
3). You can keep the current sections in the hash table, which is updated every time you change the view.

Please, see the working sample:
https://snippet.dhtmlx.com/5/ef1fdcddc