更改FullCalendar月视图上的默认事件排序顺序 [英] Change default event sort order on FullCalendar month View

查看:657
本文介绍了更改FullCalendar月视图上的默认事件排序顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个全日历处理的月份视图中显示的多个日历.不同的日历用颜色编码.我在所有视图上都按名称对日历进行了排序,但是当它们在FullCalendar显示中呈现时,它们将按事件的标题进行排序.

I have a fullcalendar working with multiple calendars displayed in the month view. The different calendars are color coded. I have the calendars sorted by name on all views, but when they are rendered in the FullCalendar display they are sorted by title of the event.

总有一天可以覆盖默认的排序方式吗?

Is there anyway to override the default sort for the day?

推荐答案

如果要完全覆盖allDaySlot,月份,基本视图的按开始日期排序. 例如,按颜色对它们进行排序.

If you want to completely override the sorting by start date for allDaySlot, month, basics views. For example to sort them by color.

1.Initialise eventOrder 进行着色. (您使用的html/php文件)

1.Initialise eventOrder to color. (html/php file you are using)

eventOrder: 'color,start'

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

2.Change the compareSegs function. (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测试.

In this case I only want to sort event by color in the "basicVeek" view. Then I have remove the eventStartMS & eventDurationMS tests.

删除:

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

这篇关于更改FullCalendar月视图上的默认事件排序顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆