Search code examples
javascriptfullcalendarfullcalendar-schedulerfullcalendar-5

Fullcalendar Scheduler 5 programmatically expand resource group


iam using fullcalendar-Scheduler 5.2.

How can i expnad or collapse a resourcegroup? i know the resourcesInitiallyExpanded function, but i want to expand/collapse a specific resourceGroup.

i found an example: https://codepen.io/anon/pen/odNOWZ?editors=0010 but this is for an old version of Fullcalendar.

viewRender: function(view) { 
      $('#calendar .fc-divider .fc-cell-text').each(function(index, area_text_el) {
        if (area_text_el.innerText === 'Auditorium A') {
          $(area_text_el).siblings('.fc-expander').click()
        }
      })

i will use the resourceGroupLabelDidMount hook which gives me this args:

When the above hooks are specified as a function in the form function(arg), the arg is an object with the following properties:

groupValue

el - the element. only available in resourceGroupLabelDidMount, resourceGroupLabelWillUnmount, resourceGroupLaneDidMount, and resourceGroupLaneWillUnmount

But where can call the click function?

Thanks !


Solution

  • Okay i figured it our yesterday (after some try'n error)

    this is the way i do it:

    resourceGroupLabelDidMount:function(info){
      if(info.groupValue === 'Auditorium B'){
                 info.el.querySelector('.fc-datagrid-expander')
            .click();
      }