按开始日期和结束日期排列Fullcalendar中的事件

如何在开始日期之前在fullCalendar中排序事件?

例:

  • 首先开始的事件将显示在最上面,然后稍后开始的事件将在稍后显示
  • 如果两个事件的开始日期相同,则按结束日期排序,即先结束的事件将首先显示,然后是稍后结束的事件。
  • 日历显示事件顺序

    var args = jQuery.parseJSON(emCalendarArgs);
    var Jobj = args.events;
    
    // Setup FullCalendar
    
    (function() {
      //var language = jQuery('#pg_lang').val();
      //alert(language+ 'dsfsd');
      var date = new Date();
      var d = date.getDate();
      var m = date.getMonth();
      var y = date.getFullYear();
      var language = langg;
      var mn_text, week_text, day_text, list_text;
    
      //alert(mn_text);
      var args = jQuery.parseJSON(emCalendarArgs);
      var Jobj = args.events;
      console.log(Jobj);
      jQuery('#events-full-calendar').fullCalendar({
    
        allDaySlot: false,
        editable: true,
        lang: 'he',
        handleWindowResize: true,
        eventOrder: 'start,end',
        header: {
          left: 'today prev,next',
          center: 'title',
          right: 'month,basicWeek,basicDay'
        },
        buttonText: {
          month: mn_text,
          week: week_text,
          day: day_text
        },
        eventLimit: {
          'month': 3, // adjust to 4 only for months
          'default': false // display all events for other views
        },
        axisFormat: 'HH:mm',
        timeFormat: {
          agenda: 'H:mm{ - h:mm}'
        },
        slotEventOverlap: false,
        events: Jobj,
        timeFormat: 'H:mm',
      });
    }());
    

    我找到了一个解决方案。 对于其他寻找解决方案的人来说,我改变了fullcalendar.js中的一个函数:

    compareSegs: function(seg1, seg2) { return seg1.eventStartMS - seg2.eventStartMS || // earlier events go first seg2.eventDurationMS - seg1.eventDurationMS || // tie? longer events go first seg2.event.allDay - seg1.event.allDay || // tie? put all-day events first (booleans cast to 0/1) compareByFieldSpecs(seg1.event, seg2.event, this.view.eventOrderSpecs); } 
    

    至 :

    compareSegs: function(seg1, seg2) {
            if(this.view.name=="basicWeek" || this.view.name=="month" || this.view.name=="basicDay"){ // ordering events by color in ListView
            return seg2.event.allDay - seg1.event.allDay || // tie? put all-day events first (booleans cast to 0/1)
                compareByFieldSpecs(seg1.event, seg2.event, this.view.eventOrderSpecs);
            }
            else{
                return seg1.eventStartMS - seg2.eventStartMS || // earlier events go first
                            seg2.eventDurationMS - seg1.eventDurationMS || // tie? longer events go first
                            seg2.event.allDay - seg1.event.allDay || // tie? put all-day events first (booleans cast to 0/1)
                            compareByFieldSpecs(seg1.event, seg2.event, this.view.eventOrderSpecs);
            }
        }
    

    并在fullcalendar函数中使用以下代码

    eventOrder: 'start, end' 
    

    在我fullcalendar调用

    链接地址: http://www.djcxy.com/p/81275.html

    上一篇: Order Events in Fullcalendar by Start date and End Date

    下一篇: FullCalendar End Date Off By One