添加事件到一天中的每一天都是空的

时间:2015-02-24 22:25:13

标签: javascript jquery fullcalendar

为了更好地理解我的问题,请查看JSFiddle Example

基本上,日历上有一些树类的独特项目是全天事件:今天已完成不完整天。我需要想办法填充那些没有任何内容的日子(今天或不完整),在这种情况下,他们会填充" 已完成" 。我怎么能弄清楚这些日子是什么?

还可以将日历限制在设定的月份范围内吗?例如,第1季将是12月1日至3月31日。

//Calendar
$(document).ready(function() {

    // Figure out todays date and provide link to enter data
    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();

    // Staff Data Calendar
    $('#calendar-staff').fullCalendar({
        header: {
                left: '',
                center: 'title',
            },
        businessHours: true, // display business hours
        handleWindowResize: true, // responsive layout
        editable: false,
        events: [
                // red areas where no events can be dropped
                {
                    title: 'No Data',
                    start: '2015-02-03',
                    url: '#',
                    color: '#E64C65'
                },
                {
                    title: 'No Data',
                    start: '2015-02-17',
                    url: '#',
                    color: '#E64C65'
                },
                {
                    // Display Today
                    title: 'Enter Data for Today',
                    url: 'staffing_data_edit.html',
                    color: '#5E9EF3',
                    start: new Date(y, m, d)
                }

            ]

    });
});

1 个答案:

答案 0 :(得分:0)

您可以对事件 dayRender Click here for reference

使用并应用自定义检查

或者您可以使用事件 eventAfterAllRender ,该事件在准备绘制日历后调用。您可以使用循环检查空天。

IF OBJECT_ID('tempdb..#ValidRecords') IS NOT NULL
    DROP TABLE #ValidRecords

SELECT DISTINCT t2.[Name]
INTO #ValidRecords
FROM @test1 t1
JOIN @test2 t2 ON t1.Ref = t2.P_Ref
WHERE t1.Dates IS NOT NULL

SELECT Ref,
t2.P_Ref,
t2.[Name]
FROM @test1 t1
RIGHT JOIN @test2 t2 ON t1.Ref = t2.P_Ref
INNER JOIN #ValidRecords vr ON vr.[Name] = t2.[Name]