views:

1132

answers:

3

I am integrating jQuery plugin FullCalendar, overall it has been really straightforward. I however have ran into a problem with adding events to the calendar. I am using ASP.NET MVC 1.0 and have found and followed this post.

I am returning JSON to the FullCalendar and the events are getting bound, but they all show up as all day events. I am formatting the dates as ISO8601 format as documented at their site.

Calendar Javascript

$('#calendar').fullCalendar({
    events: "/Calendar/GetEvents/"
});

JsonResult

public JsonResult GetEvents(double start, double end)
{
    var fromDate = Utility.Dates.ConvertFromUnixTimestamp(start);
    var toDate = Utility.Dates.ConvertFromUnixTimestamp(end);

    List<GenericEventList> events = GETGENERICLISTOFEVENTS();
    return Json(events.ToArray()); 
}

JSON Result Value

[{"id":2,"title":"Test Event","start":"2010-03-14T11:00:00","end":"2010-03-14T16:00:00"},
{"id":3,"title":"Test Event1asasas","start":"2010-03-14T10:00:00","end":"2010-03-14T14:00:00"},
{"id":4,"title":"Test Event12","start":"2010-03-14T16:00:00","end":"2010-03-14T17:00:00"},
{"id":6,"title":"Test Event1aaa","start":"2010-03-14T10:00:00","end":"2010-03-14T14:00:00"}]

Any help is truly appreciated!

+4  A: 

make sure to set the allDay property to false for each event object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)

arshaw
Thanks @arshaw, worked like a charm! By the way, fanatic plugin!
Dustin Laine
Also, now you can add `allDayDefault: false` to your calendar options to have this be the default. @arshaw: Thanks so much for the calendar, it's be a pleasure to use/integrate so far.
sdolan
A: 

Thanks!!!!Very helpful!

You should not answer this, you should add comment an up vote someone elses answer.
Dustin Laine
A: 

Also, if your dates aren't padded with zeros, then the events won't show.
Ex. 2010-9-5 bad
Ex. 2010-09-05 good

Don Rolling