FullCalendar中显示2周

FullCalendar中显示2周

本文介绍了在jQuery FullCalendar中显示2周的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

四处寻找一种方法,只显示的月视图中的当前周和下周>。到目前为止,它似乎被认为是即将推出的版本的一个功能,但与此同时,任何人都能够入侵它?



UPDATE



感谢Doomsday的建议,我能够创建一个自定义视图,显示本周开始的2周。您将可见的开始日期更改为今天的日期并将行数更改为2。

 函数TwoWeeksView(element,calendar){ 
var t = this;

//导出
t.render = render;


//进口
BasicView.call(t,element,calendar,'month');
var opt = t.opt;
var renderBasic = t.renderBasic;
var formatDate = calendar.formatDate;



函数render(日期,delta){
if(delta){
addMonths(date,delta);
date.setDate(1);
}
var start = cloneDate(date,true);
start.setDate(1);
var end = addMonths(cloneDate(start),1);

// var visStart = cloneDate(start);
var visStart = date;

var visEnd = cloneDate(end);
var firstDay = opt('firstDay');
var nwe = opt('weekends')? 0:1;
if(nwe){
skipWeekend(visStart);
skipWeekend(visEnd,-1,true); $(b)b

addDays(visStart, - ((visStart.getDay() - Math.max(firstDay,nwe)+ 7)%7));
addDays(visEnd,(7 - visEnd.getDay()+ Math.max(firstDay,nwe))%7);
var rowCnt = Math.round((visEnd - visStart)/(DAY_MS * 7));如果(opt('weekMode')=='fixed'){
addDays(visEnd,(6 - rowCnt)* 7);

if
// rowCnt = 6;
rowCnt = 2;
}
t.title = formatDate(start,opt('titleFormat'));
t.start = start;
t.end = end;
t.visStart = visStart;
t.visEnd = visEnd;
renderBasic(6,rowCnt,nwe?5:7,true);
}
}


解决方案

最好的解决方案是它实现您的自定义视图。

放入一个新的JS你自己定义的视图:

  $。fullCalendar.views.twoweeks = TwoWeeksView; 
函数TwoWeeksView(元素,日历){
//从fullcalendar.js行复制代码1960
}


Been looking around for a way to display only the current week and the next week in the month view for FullCalendar. So far it looks like it was suggested as a feature for an upcoming version, but in the meantime, has anyone been able to hack it in?

UPDATE

Thanks to Doomsday's suggestion, I was able to create a custom view that shows 2 weeks, starting on the current week. You are changing the visible start date to today's date and changing the row count to 2.

function TwoWeeksView(element, calendar) {
var t = this;

// exports
t.render = render;


// imports
BasicView.call(t, element, calendar, 'month');
var opt = t.opt;
var renderBasic = t.renderBasic;
var formatDate = calendar.formatDate;



function render(date, delta) {
    if (delta) {
        addMonths(date, delta);
        date.setDate(1);
    }
    var start = cloneDate(date, true);
    start.setDate(1);
    var end = addMonths(cloneDate(start), 1);

    //var visStart = cloneDate(start);
    var visStart = date;

    var visEnd = cloneDate(end);
    var firstDay = opt('firstDay');
    var nwe = opt('weekends') ? 0 : 1;
    if (nwe) {
        skipWeekend(visStart);
        skipWeekend(visEnd, -1, true);
    }

    addDays(visStart, -((visStart.getDay() - Math.max(firstDay, nwe) + 7) % 7));
    addDays(visEnd, (7 - visEnd.getDay() + Math.max(firstDay, nwe)) % 7);
    var rowCnt = Math.round((visEnd - visStart) / (DAY_MS * 7));

    if (opt('weekMode') == 'fixed') {
        addDays(visEnd, (6 - rowCnt) * 7);
        //rowCnt = 6;
        rowCnt = 2;
    }
    t.title = formatDate(start, opt('titleFormat'));
    t.start = start;
    t.end = end;
    t.visStart = visStart;
    t.visEnd = visEnd;
    renderBasic(6, rowCnt, nwe ? 5 : 7, true);
}
}
解决方案

The best solution is it to implement your custom view.

Put in a new JS your own defined view :

$.fullCalendar.views.twoweeks = TwoWeeksView;
function TwoWeeksView(element, calendar) {
    // copy code from fullcalendar.js line 1960
}

这篇关于在jQuery FullCalendar中显示2周的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 16:58