我们如何使用fullcalendar指定自定义日期范围? [英] How can we specify custom date range with fullcalendar?

查看:1632
本文介绍了我们如何使用fullcalendar指定自定义日期范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为自定义日期范围使用fullcalendar。它应该显示特定日期范围的视图,例如从4月15日到5月4日(跨度在两个月之间)。

I want to use fullcalendar with custom date range for ex. it should display view for particular date range like from 15th April to 4th May(Spans between two months).

有什么建议?。

Any suggestions?.

推荐答案

你可以在日期范围内调用这个函数来gt事件。但这会给你带来30天的时间。如果你通过像'01 -may-2013'这样的日期到2013年6月15日',那么它会显示2013年5月1日到2013年5月30日的数据。我知道你是否可以找到这个问题的任何线索。

you can call this function to gt events in date range. but this will bring you only 30 days evnt. if you pass dates like '01-may-2013' to 15-June-2013' then it will show data from 01-may2013 to 30st may 2013. Lt me know if you can find any clue for this issue.

function GetAgendaEvents(datefrom, dateTo) {

    var fromDate = new Date($("#from").val());
    var toDate = new Date($("#to").val());

    if (fromDate.getTime() <= toDate.getTime()) {

        $('#fullcal').fullCalendar('removeEvents').fullCalendar('addEventSource', events);
        $('#fullcal').fullCalendar('refetchEvents');

        var filteredEvent = $('#fullcal').fullCalendar('clientEvents', function (event) {
            return event.start >= fromDate && event.start <= toDate;

        });
       $('#fullcal').fullCalendar('gotoDate', fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate());
        $('#fullcal').fullCalendar('changeView', 'agenda'/* or 'basicDay' */);

        $('#fullcal').fullCalendar('removeEvents').fullCalendar('addEventSource', filteredEvent);
        $('#fullcal').fullCalendar('refetchEvents');



    }

}

这篇关于我们如何使用fullcalendar指定自定义日期范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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