简体   繁体   English

全日历在周视图中仅移动 1 天(上一个/下一个)

[英]Fullcalendar move only by 1 day (prev/next) in week view

Is there a way in fullcalendar on the week view to move by 1 day (next/prev buttons) instead of jumping 1 week back and forth?有没有办法在周视图的全日历中移动 1 天(下一个/上一个按钮)而不是来回跳跃 1 周?

The reason behind is because when I create an event on the week view I am limited to the last day and can't prolong it to the next week...背后的原因是因为当我在周视图中创建事件时,我仅限于最后一天,不能将其延长到下周......

They now have added dateIncrement as a option.他们现在添加了dateIncrement作为选项。

$('#calendar').fullCalendar({
  header: {
    left: 'today prev,next',
    center: 'title',
    right: 'CustomW,CustomF,CustomS',
  },
  views: {
    CustomW: {
      type: 'timelineWeek',
      duration: { days: 7 },
      buttonText: 'Week',
      dateIncrement: { days: 1 },
    },
    CustomF: {
      type: 'timelineWeek',
      duration: { days: 15 },
      buttonText: '15 day',
      dateIncrement: { days: 4 },
    },
    CustomS: {
      type: 'timelineMonth',
      duration: { days: 30 },
      buttonText: 'Month',
      dateIncrement: { days: 10 },
    },
  },

Okay I figured out how to make this work for both subtraction and addition.好吧,我想出了如何使这项工作既适用于减法又适用于加法。 I had to alter the fullcalendar.js file itself which means there could be some other complications as I have not tested this beyond clicking the next and previous buttons.我不得不更改 fullcalendar.js 文件本身,这意味着可能还有其他一些复杂情况,因为除了单击下一个和上一个按钮之外,我还没有对此进行测试。 I would not recommend doing this approach if you plan on utilizing more than one view.如果您打算使用多个视图,我不建议您采用这种方法。

Force currentview to change on click强制当前视图在单击时更改

Comment out lines 9741 - 9747 and 9759 This allows the currentview to change when clicking the next button even though you haven't actually left the currentview注释掉第 9741 - 9747 和 9759 行 这允许在单击下一步按钮时更改当前视图,即使您实际上并未离开当前视图

Previous Click上一次点击

Line 7931 needs to be changed to 7931行需要改成

date.clone().startOf('day').subtract(1)

Next Click下一步点击

Line 7939 needs to change to 7939行需要改成

date.clone().startOf('day').add(1, 'day')

You can create custom view like this:您可以像这样创建自定义视图:

$('#calendar').fullCalendar({
header: {
    center: 'month,basicWeekOneDay' // buttons for switching between views
},
views: {
    basicWeekOneDay: {
        type: 'basicWeek',
        duration: { days: 1 },
        buttonText: '1 day'
    }
}

}); });

Here is fiddle for the same: https://jsfiddle.net/raj20090/j99f7zqw/2/这是相同的小提琴: https : //jsfiddle.net/raj20090/j99f7zqw/2/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM