sorting - 更改 FullCalendar 月 View 上的默认事件排序顺序

标签 sorting fullcalendar

我有一个完整日历,可在月 View 中显示多个日历。不同的日历采用颜色编码。我在所有 View 上按名称对日历进行排序,但是当它们在 FullCalendar 显示中呈现时,它们是按事件的标题排序的。

有没有办法覆盖当天的默认排序?

enter image description here

最佳答案

如果您想完全覆盖所有DaySlot、月份、基本 View 的开始日期排序。 例如按颜色对它们进行排序。

1.初始化eventOrder填色。 (您正在使用的 html/php 文件)

eventOrder: 'color,start'

2.更改compareSegs函数。 (fullcalendar.js)

// original function
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);
}

// custom function
compareSegs: function(seg1, seg2) {
    if(this.view.name=="basicWeek"){ // 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);
    }
}

在这种情况下,我只想在“basicVeek” View 中按颜色对事件进行排序。 然后我删除了 eventStartMS 和 eventDurationMS 测试。

删除:

seg1.eventStartMS - seg2.eventStartMS || // earlier events go first
seg2.eventDurationMS - seg1.eventDurationMS || // tie? longer events go first

关于sorting - 更改 FullCalendar 月 View 上的默认事件排序顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22252552/

相关文章:

javascript - FullCalendar.js 调整移动标题

javascript - 如果有使用 fullCalendar 的事件,则突出显示日期

algorithm - 按顺序找到k个最大的元素

Angular Material 排序表 - 如何将标题文本右对齐?

Java8 对 Map 内的 Map 值进行排序

python - 在python中重新排序固定长度数组

python - 使用排序在 python 中使用命名元组进行编码

php - 当 allday 为 false 时,FullCalendar 不显示来自 JSON 事件的时间

javascript - FullCalendar 通过 event.id 或 event.source 删除所有 eventSource 或事件

jquery - fullcalendar js 中未显示的事件