全日历月视图-调整为每月的实际周数 [英] Fullcalendar Month View - adjust to actual number of weeks in month

查看:189
本文介绍了全日历月视图-调整为每月的实际周数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用最新的fullcalendar.io,月份视图中显示的星期数适合呈现的第一个月.使用上一个/下一个按钮时,如果下一个/上一个月的周数少于当前月份,则仍显示当前月的周数.

Using latest fullcalendar.io, the number of weeks that are displayed in month view is appropriate for the first month that renders. When using the prev/next buttons, if the next/prev month has less weeks than the current month, it still renders the current month's number of weeks.

现在是2015年5月.该站点上的演示位于: http://fullcalendar.io/js/fullcalendar-2.3.1/demos/gcal.html

Right now it's May 2015. The demo on the site is here: http://fullcalendar.io/js/fullcalendar-2.3.1/demos/gcal.html

2015年5月的渲染需要6周的时间,因为这是需要的数量.当我单击下一步转到2015年6月时,即使只需要5个星期,在月视图中仍会显示6个星期.

May 2015 renders with 6 weeks, because that's how many are needed. When I click next to go to June 2015, 6 weeks are still rendered in month view, even though only 5 weeks are needed.

问题:呈现的周数如何调整为给定月份的实际周数?这意味着2015年5月将有6周,但表格将减少到2015年6月的5周.

Question: how can the number of weeks that gets rendered adjust to the actual number of weeks that a given month has? This means that May 2015 would have 6 weeks, but the table would reduce to 5 weeks for June 2015.

这在尝试打印月历时很重要.现在是五月,但是有人可能要单击下一步"并打印即将到来的六月. 6月的日历应该只有5周,但是自从5月进入6月以来,我只能将其显示为6.

This is important when trying to print a monthly calendar. It's May right now, but someone might want to click next and print June, which is coming up. The June calendar should only have 5 weeks, but I can only make it display with 6, since I entered June from May.

仅感谢您提供提示. 瑞安

Thanks for only tips on this. ryan

推荐答案

您在寻找 fixedWeekCount 选项.从文档中,您可以看到:

Your looking for the fixedWeekCount option. From the documentation, you can see that:

如果为true,则日历将始终为6周.如果为false,则日历将有4周,5周或6周,具体取决于月份.

If true, the calendar will always be 6 weeks tall. If false, the calendar will have either 4, 5, or 6 weeks, depending on the month.

因此,如果要显示每个选定月份的正确星期数,则应在初始化fullCalendar时将该选项设置为false:

So, if you want to display the correct number of weeks per selected month, you should set that option to false when fullCalendar is initialized:

$('#calendar').fullCalendar({
    fixedWeekCount: false
});

请查看此jsfiddle ,以了解有效的演示.

Take a look at this jsfiddle for a working demo.

这篇关于全日历月视图-调整为每月的实际周数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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