Jquery全日历控制与假期的颜色

时间:2012-11-02 06:47:30

标签: jquery jquery-plugins fullcalendar

我使用jquery fullcalander控件。我想在月视图中为假期着色。点击假期后打开关于假期的消息 我用事件把假期送到calander。但它不起作用 任何人都可以帮助我

 $('#calendar').fullCalendar
         ({


             allEvent: {
                 titles: '.........',
                 start: '07/24/2012'
             },

             eventSources: [
             {
            url: '@Url.Action("LeaveCalandar")',
            type: 'Get',
           data{username:user},
           dataType:"JSON",
            success: function() {
                alert('there was an error while fetching events!');
            },
            color: 'yellow',   
            textColor: 'black' 
        }

        // any other sources...

    ],
             eventClick: function (calEvent, allDay) {
                 // $('#eventTitle').text(calEvent.title);
                 // alert(calEvent.title);
                 eventName = calEvent.title;
                 ShowDialog(eventName);
                 ShowDialog(calEvent.titles);

             },

这是我的事件calandar行动方法

public JsonResult EventCalendarData(string username)
        {
        List<CalendarEvents> events = new List<CalendarEvents>();
        List<LeaveTransaction> leaveQuery;
        var query = (from sh in db.StatHolidays
                     select sh).ToList();
        if (!string.IsNullOrEmpty(username))
        {
             leaveQuery = db.LeaveTransactions
                .Where(lt=>lt.Employee.UserName.Contains(username))
                            .Select(lt => lt).ToList();
        }
        else
             leaveQuery = db.LeaveTransactions
                            .Select(lt => lt).ToList();

        foreach (var item in query)
        {
            events.Add(new CalendarEvents
                {
                    id = item.ID.ToString(),
                    title = item.Description,
                    start = ToUnixTimespan(item.DateofStatHoliday),
                    className = "custom",
                    allDay = true,
                });

        }
        foreach (var item in leaveQuery)
        {
            events.Add(new CalendarEvents
            {
                id = item.Id.ToString(),
                title = item.LeaveType.Type,
                start = ToUnixTimespan(item.StartDate),
                end =ToUnixTimespan(item.EndDate),
                className = "custom",
                allDay = true,
            });

        }

        return Json(events, JsonRequestBehavior.AllowGet);
    }

0 个答案:

没有答案