Kamila
Kamila

Reputation: 399

fullcalendar.sj limitEvents in agendaWeek view

I'm trying to find a way to limit non-all day events in week view. According to documentation I should use fallowing option:

$('#calendar').fullCalendar({
    eventLimit: {
        'agenda': 6, // adjust to 6 only for agendaWeek/agendaDay
        'default': true // give the default value to other views
    }
});

which, unfortunately, works only for all day events in week view.

In the case a company has many overlapping events, week view is just useless since it looks like that:

Image

Upvotes: 0

Views: 970

Answers (1)

warath-coder
warath-coder

Reputation: 2122

unfortunatly fullCalendar is working, as it will limit the events for the particular day, not time slot however.

You will likely have to write your own method to track number of events in a time slot.

consider using the eventRender event and hide events after X number of events for that timeslot have been found.

something like:

var eventSlots = {};

eventRender: function(event, element, view) {
    var slotId = event.start.format('YYYYMMDDhh');
    if !(slotId in eventSlots) {
        eventSlots[slotId] = 1;
    } else {
        eventSlots[slotId]++;
        if ( eventSlots[slotId] > X ) {
            element.find('.fc-event').addClass('hidden');
        }
    }
}

i've not tested the above, but think something like that should work for you.

things to keep in mind, your slot size and if partial overlaps occur will require more logic and customization of the 'slotId'

Upvotes: 1

Related Questions