FullCalendar:如何排序&在月视图中显示事件? [英] FullCalendar: How to sort & display Events on Day of MonthView?

查看:622
本文介绍了FullCalendar:如何排序&在月视图中显示事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每月视图中每天的所有事件都会根据开始时间进行排序,即事件开始时间为0-23小时0,最高为23小时。

但我想在活动任务列表的顶部和之后显示活动( event.IsActive == true )任务,非活动( event.IsActive =


$ b 示例:


$ b $ = $ false b


  1. ActiveTask-1 12:00上午

  2. ActiveTask-2上午3:00

  3. ActiveTask-3 21: InactiveTask-1 7:00 AM

  4. 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:

  1. ActiveTask-1 12:00AM
  2. ActiveTask-2 3:00AM
  3. ActiveTask-3 21:45PM
  4. InactiveTask-1 12:00AM
  5. InactiveTask-2 7:00AM
  6. 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.jsfor 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屋!

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