FullCalendar:如何排序&在月视图中显示事件? [英] FullCalendar: How to sort & display Events on Day of MonthView?
问题描述
但我想在活动任务列表的顶部和之后显示活动( event.IsActive == true
)任务,非活动( event.IsActive =
$ b 示例:
$ b $ = $ false b
- ActiveTask-1 12:00上午
- ActiveTask-2上午3:00
- ActiveTask-3 21: InactiveTask-1 7:00 AM
- InactiveTask-1 12:00 AM InactiveTask-3 23 :30PM
这可能在fullCalendar中吗?
您的请求需要直接修补fullcalendar代码。
这是强制性的,因为fullcalendar不会将此函数暴露给外部世界。
我没有检查我的1.4.11版本的响应, 1.5分支在github上显示它应该是相同的。
要修补的函数是 segCmp
,在源代码版本的 src / util.js
中,或者在fullcalendar.js文件末尾附近)
函数segCmp(a,b){
return(b.msLength - a .msLength)* 100 +(a.event.start - b.event.start);
}
修补后的版本应如下所示:
function segCmp(a,b){
var activeDiff =((b.event.IsActive || false) - (a.event.IsActive | | false));
if(activeDiff!= 0)返回activeDiff;
return(b.msLength - a.msLength)* 100 +(a.event.start - b.event.start);
}
我只需检查事件是否有不同的IsActive状态并返回差异,如果没有差异,则保留先前的算法。 (请注意b - diff,因为您需要IsActive:true BEFORE IsActive:false)
请注意, segCmp
是在分裂/排序事件时被调用,因此将适用于所有视图。
最好的问候,
Pascal
p>All events on day slot of monthly view are sorted based on the start time i.e. event start hour 0-23, hour 0 on top and 23 on bottom.
But I want to show the active(event.IsActive == true
) tasks on top and after the Active task list, inactive(event.IsActive == false
) tasks will be displayed sorted by start hour 0-23.
Example:
- ActiveTask-1 12:00AM
- ActiveTask-2 3:00AM
- ActiveTask-3 21:45PM
- InactiveTask-1 12:00AM
- InactiveTask-2 7:00AM
- InactiveTask-3 23:30PM
Is this possible in fullCalendar?
Your request will need to directly patch the fullcalendar code. This is mandatory because fullcalendar doesn't expose this function to the outside world.
I did check my response with version 1.4.11, but looking at the 1.5 branch on github shows that it should be the same.
The function to be patched is segCmp
, (found in src/util.js
for the source version, or simply near the end of the file in fullcalendar.js)
The original version is:
function segCmp(a, b) {
return (b.msLength - a.msLength) * 100 + (a.event.start - b.event.start);
}
The patched version should look like that:
function segCmp(a, b) {
var activeDiff = ((b.event.IsActive || false) - (a.event.IsActive || false));
if (activeDiff != 0) return activeDiff;
return (b.msLength - a.msLength) * 100 + (a.event.start - b.event.start);
}
I simply check wether the events have a different IsActive state and return the diff, if no diff the previous algorithm is preserved. (Note the b - a diff because you want IsActive:true BEFORE IsActive:false)
Note that segCmp
is called when splitting/ordering events and thus will apply in all views.
Best Regards,
Pascal
这篇关于FullCalendar:如何排序&在月视图中显示事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!