FullCalendar switch between weekends and no weekends

后端 未结 7 1442
天命终不由人
天命终不由人 2021-01-14 15:48

I was wondering if there was a way in Arshaw\'s FullCalendar to: 1- Change the calendar from showing weekends to not show weekends and vice versa. 2- To dynamically change t

7条回答
  •  独厮守ぢ
    2021-01-14 16:31

    For toggling weekends:

    1. Create a Custom View
    2. Set weekends to false in the custom view's properties
    3. Add the name of your custom view to your header, so that a button will appear for this view.
    4. Use defaultView to set the your initial view

    $('#calendar').fullCalendar({
        //defaultView: 'agendaWeekdays',
        header: {
            right: 'month,monthWeekdays,agendaWeek,agendaWeekdays'
        },
        views: {
            agendaWeekdays: {
                buttonText: 'Weekdays',
                type: 'agendaWeek',
                weekends: false
            },
            monthWeekdays: {
                buttonText: 'Month (Weekdays)',
                type: 'month',
                weekends: false
            }
        }
    });
    

    As for slot duration, you could destroy the calendar and create it again with the slotDuration property changed.

    Alternatively, you could create more Custom Views, each with different slotDurations. You wouldn't need to add buttons for these views to the header but instead create your own UI for slot duration that calls your custom views.


    $('#calendar').fullCalendar('changeView', 'agendaWeekdaysSlotDuration15');
    

提交回复
热议问题