只需在fullcalendar中显示几天

时间:2013-08-15 09:31:29

标签: jquery fullcalendar

如何配置fullcalendar只显示几天。因为我想让用户在几天内创建自己的活动。

1 个答案:

答案 0 :(得分:0)

不确定我完全理解这个问题。你想隐藏特定的工作日吗?或者您是否要限制用户仅为一个月中的特定日期创建活动?

如果您想隐藏特定的工作日,可以使用'hiddenDays'属性轻松完成此操作,如下所述:http://arshaw.com/fullcalendar/docs/display/hiddenDays/

如果您想要隐藏一个月内的具体日期,我认为没有规定这样做。但是,您可以使用'dayClick'功能来检查点击日期是否是您希望用户创建事件的日期,如果是,请从那里继续,否则让用户知道在该特定日期无法创建事件。 dayClick文档可在以下位置找到:http://arshaw.com/fullcalendar/docs/mouse/dayClick/

此外,您可以使用'dayRender'在渲染一天时获得回调(它呈现为每个日期带有'td'标记的表格单元格),以便您可以添加CSS类(例如'禁用')对于没有允许事件创建的日期,在检查日期后的日历的特定单元格中,以便让用户知道是否可以在该特定日期创建事件。有关此文档,请访问:http://arshaw.com/fullcalendar/docs/display/dayRender/

编辑 - (在OP评论后编辑......)

从你的评论中,我认为情况相当棘手。正如你正确提到的那样,agendaWeek没有'dayRender'回调。我能想到的唯一选择是拼凑一个相当肮脏的黑客。根据我的发现,agendaWeek(最新的fullcalendar版本)的结构如下所示:

<table class="fc-agenda-days fc-border-separate">
    <thead>
        <tr class="fc-first fc-last">
            <th class="fc-agenda-axis fc-widget-header fc-first">&nbsp;</th>
            <th class="fc-sun fc-col0 fc-widget-header">Sun 8/11</th>
            <th class="fc-mon fc-col1 fc-widget-header">Mon 8/12</th>
            <th class="fc-mon fc-col2 fc-widget-header">Tue 8/13</th>
            ...
        </tr>
    </thead>
    <tbody>
        <tr class="fc-first fc-last">
            <th class="fc-agenda-axis fc-widget-header fc-first">&nbsp;</th>
            <td class="fc-col0 fc-sun fc-widget-content fc-past">...</td>
            <td class="fc-col1 fc-mon fc-widget-content fc-past">...</td>
            <td class="fc-col2 fc-tue fc-widget-content fc-past">...</td>
            ....
        </tr>
    </tbody>
</table>

如果您以某种方式解析$(“table.fc-agenda-days th.fc-col *”)中的日期以及要禁用的日期,请将CSS类添加到$(“table.fc-agenda设置新背景的-days td.fc-col *“)你应该好好去。这当然是处理'dayClick'回调的补充。

这可以在'viewRender'回调中完成(在检查视图类型是否为agendaWeek之后)。希望这会把你推向正确的方向......如果你被困在某个地方,请告诉我......

相关问题