我有一个fullcalendar,可以在月视图中显示多个日历。不同的日历是彩色编码的。我在所有视图上按名称排序日历,但是当它们在FullCalendar显示中呈现时,它们按事件的标题排序。
无论如何都要覆盖当天的默认排序?
答案 0 :(得分:4)
如果要完全覆盖allDaySlot,month,basics视图的开始日期排序。 例如,按颜色对它们进行排序。
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”视图中按颜色对事件进行排序。 然后我删除了eventStartMS& eventDurationMS测试。
删除:
seg1.eventStartMS - seg2.eventStartMS || // earlier events go first
seg2.eventDurationMS - seg1.eventDurationMS || // tie? longer events go first
答案 1 :(得分:0)
eventOrder: "eventProperty"
更多信息:https://fullcalendar.io/docs/event_rendering/eventOrder/
答案 2 :(得分:-1)