FullCalendar limit number of events and have a MORE link

前端 未结 5 1669
暗喜
暗喜 2020-12-19 17:33

I have seen that there has been a request to add a MORE link, to the calendar and limit the number of events. Is this done yet? Or has anyone implemented there own work arou

5条回答
  •  攒了一身酷
    2020-12-19 18:02

    I handle this on eventRender. The code is something like this with maxEvents being whatever you want to set the max to and BuildMoreLink(currentMoreNum) builds your link. Returning false prevents the item from being added to your calendar.

        eventRender: function (event, element) {
            var eventDateString = GetDateInCalFormat(event.start);
            var $calDay = $('td.fc-day[data-date="' + eventDateString + '"]');
            var dayEventCount = $calDay.attr('dayEventCount') ? parseInt($calDay.attr('dayEventCount')) : 0;
    
            dayEventCount = dayEventCount + 1;
            $calDay.attr('dayEventCount', dayEventCount);
    
            if (dayEventCount <= maxEvents) {
               //[any custom formatting]
            }
            else {
                var missingEvents = dayEventCount - maxEvents;
                $('.moreLink', $calDay).remove();
                $moreLink = $('

    Oh yeah and here is my formatter for getting the correct date value to find the day:

    function GetDateInCalFormat(dateToFormat) {
        dd = dateToFormat.getDate();
        mm = dateToFormat.getMonth() + 1;
        yyyy = dateToFormat.getFullYear();
        if (dd < 10) { dd = '0' + dd }
        if (mm < 10) { mm = '0' + mm }
        results = yyyy + '-' + mm + '-' + dd;
        return results;
    }
    

提交回复
热议问题