2013-10-02 162 views
0

我在fullcalendar上顯示事件時遇到了一些麻煩。有人可以幫忙嗎? 它一直工作得很好,直到我在數據庫中引入結束日期。我已經嘗試從日曆中刪除它,但它仍然無法工作。全日曆沒有顯示的事件

我想綁定我的mvc控制器返回的json數據。 JSON的外觀精緻,並即將爲:

{ id = 1, title = "XYZ Apple", start = "2013-10-02T00:00:00.0000000", end = "2013-10-06T00:00:00.0000000", allDay = true } 

{ id = 3, title = "XYZ Apple", start = "2013-10-03T00:00:00.0000000", end = "2013-10-10T00:00:00.0000000", allDay = true } 
{ id = 4, title = "XYZ Apple", start = "2013-10-04T00:00:00.0000000", end = "2013-10-07T00:00:00.0000000", allDay = true } 
{ id = 5, title = "XYZ Apple", start = "2013-10-07T00:00:00.0000000", end = null, allDay = true } 
{ id = 6, title = "XYZ Apple", start = "2013-10-08T00:00:00.0000000", end = "2013-10-08T00:00:00.0000000", allDay = true } 
{ id = 7, title = "XYZ Apple", start = "2013-10-09T00:00:00.0000000", end = "2013-10-15T00:00:00.0000000", allDay = true } 

在負載返回自定義錯誤:

"Error while Getting events!"

這是日曆我

var calendar = { 
    header: { 
     left: 'prev,next', 
     center: 'title', 
     right: 'today, basicDay,basicWeek,month' 

    }, 
    defaultView: 'month', 
    buttonText: { 
     today: 'Today', 
     day: 'Day', 
     week: 'Week', 
     month: 'Month', 
     prev: 'Prev', 
     next: 'Next', 

    }, 
    weekends: true, 
    editable: true, 
    events: { 
     url: 'FullCalendar/GetEvents', 
     color: 'yellow', 
     error: function() { 
      alert('Error while Getting events!'); 
     } 
    } 
}; 
myCalendar.fullCalendar(calendar); 

回答

1

您的JSON不精。它應該看起來像這樣:

[{"id":"1","title":"XYZ Apple","start":"2013-10-02T00:00:00.0000000","end":"2013-10-06T00:00:00.0000000","allDay":"true"}, 
{"id":"3","title":"XYZ Apple","start":"2013-10-03T00:00:00.0000000","end":"2013-10-10T00:00:00.0000000","allDay":"true"}] 

您可以驗證您的JSON在JSONLint

+0

問題似乎是源代碼的URL正在呈現。當我使用url作爲「GetEvents」並從同一個根運行應用程序時,它的工作原理和我現在正在做的。 – fireholster

0

在你的json數據中試試這個"allDay":"false"。 可能會幫助你。如果它不起作用,那麼靜態放置json數據並嘗試找出你所在的位置。

events: [ 
{ id = 1, title = "XYZ Apple", start = "2013-10-02T00:00:00.0000000", end = "2013-10-06T00:00:00.0000000", allDay = true }, 

{ id = 3, title = "XYZ Apple", start = "2013-10-03T00:00:00.0000000", end = "2013-10-10T00:00:00.0000000", allDay = true }, 
{ id = 4, title = "XYZ Apple", start = "2013-10-04T00:00:00.0000000", end = "2013-10-07T00:00:00.0000000", allDay = true }, 

{ id = 6, title = "XYZ Apple", start = "2013-10-08T00:00:00.0000000", end = "2013-10-08T00:00:00.0000000", allDay = true }, 
{ id = 7, title = "XYZ Apple", start = "2013-10-09T00:00:00.0000000", end = "2013-10-15T00:00:00.0000000", allDay = true }]