FullCalendar: show reversed list views

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-29 23:21:22

问题


How can I reverse the events in the list views, so that the event with the most futuristic date appears at the beginning (top)?


回答1:


@F.Mora your solution is almost perfect but in our case we add some custom classNames and have multiple items under each headline.

Here is our enhanced version :

eventAfterAllRender: function(view) {
    var renderedEvents = $('.fc-list-table  tr');
    var reorderedEvents = [];
    var blockEvents = null;
    renderedEvents.map(function(key, event) {
        if ($(event).hasClass('fc-list-heading')) {
            if (blockEvents) {
                reorderedEvents.unshift(blockEvents.children());   
            }
            blockEvents = $('<tbody></tbody>');
        }
        blockEvents.append(event);
    });
    reorderedEvents.unshift(blockEvents.children());
    $('.fc-list-table tbody').html(reorderedEvents);
}



回答2:


For anyone still looking for this, inverted event lists using jquery:

eventAfterAllRender: function(view) {
    var eventosRendered = $('#timeline tr');
    var eventosInversa = [];
    var headingPendiente = null;
    eventosRendered.map(function(key, evento) {
        switch(evento.className) {
            case 'fc-list-heading':
                if (headingPendiente) {
                    eventosInversa.unshift(headingPendiente);
                }
                headingPendiente = evento;
                break;
            case 'fc-list-item':
                eventosInversa.unshift(evento);
                break;
        }
    });
    eventosInversa.unshift(headingPendiente);

    $('#timeline tbody').append(eventosInversa);
}



回答3:


Here's the version I use (fullCalendar v4):

datesRender: function(info) {
    var list = $(info.el).find('.fc-list-table tbody');
    list.find('.fc-list-heading').each((i,heading) => {
      var children = $(heading).nextUntil('.fc-list-heading')
      list.prepend(children)
      list.prepend(heading)
    })
},


来源:https://stackoverflow.com/questions/46007392/fullcalendar-show-reversed-list-views

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!