FullCalendar-提取显示的事件



是否可以从FullCalendar对象中发现/提取当前显示的事件,(ref:http://arshaw.com/fullcalendar)?

理想情况下,我希望在日历旁边有一个事件的辅助显示,它应该只显示当前显示的事件(例如,如果日历在"2012年3月",我只想在辅助列表中看到2012年3月份的事件)。

我想我必须构建某种过滤器,但我希望我能直接从日历中提取细节。我认为插件一定已经建立了哪些是有效的显示。。。

如果我遗漏了任何指向函数/属性的指针,我们将不胜感激。

使用2.x版本,您可以通过当前视图的intervalStart&intervalEnd-我使用工厂函数getIdOrFilter来完成

App.getIdOrFilter = function () {
    var view = $('#calendar').fullCalendar('getView');
    var start = view.intervalStart;
    var end   = view.intervalEnd;
    return function (e) {
        // this is our event filter
        if (e.start >= start && e.end <= end) {
            // event e is within the view interval
            return true;
        }
        // event e is not within the current displayed interval
        return false;
    };
}
...
var events = $('#calendar').fullCalendar('clientEvents', App.getIdOrFilter());

是的,这很难做到。我最近在FullCalendar中挖掘了很多,因为我一直在为自己的目的向它添加大量额外的功能。它不以这种形式在内部存储信息,但你可以通过一个小黑客:

在第4243行插入(在完整日历1.5.2中)

t.eventResize = eventResize
//add starts
t.getShownEvents = function () {
  evs = [];
  for (id in eventElementsByID)
    evs = evs.concat(eventsByID[id]);
  return evs;
}
//add ends

然后执行此操作以获得当前显示的事件对象数组:

var evs = $('#calendar').fullCalendar('getView').getShownEvents();

感谢James Ellis-Jones,我在Full Calendar资源视图的一个分支上实现了这一点,并向Full CalendarresourceViews所有者发送了一个pull请求。

https://github.com/stephenreid/fullcalendar/commit/808a0ac2ff8e9f900af263049cc95a7d4e2b6546

最新更新