Ram
Ram

Reputation: 691

Kendo Scheduler - Event not showing

I'm trying to show the events in the Kendo Scheduler but it's not working. I think it's because the JSON date format that is coming from the server is not in the correct format. Any help is appreciated.

@(Html.Kendo().Scheduler<TaskViewModel>()
.Name("Scheduler")
.Date(DateTime.Today)
.Views(views =>
{
    views.DayView();
    views.WeekView();
    views.MonthView();
})
.Timezone("Etc/UTC")
.DataSource(d => d
    .Model(m =>
    {
        m.Field(f => f.Title);
        m.Field(f => f.Start);
        m.Field(f => f.End);
        m.Field(f => f.IsAllDay); 
    })
.Read(read => read.Action("GetScheduleEvent", "DataSource"))
)
)

JSON response

[{"RecurrenceRule":null,
  "RecurrenceException":null,
  "IsAllDay":true,
  "Start":"\/Date(1455775200000)\/",
  "StartTimezone":null,
  "End":"\/Date(1456034400000)\/",
  "EndTimezone":null,
  "Title":"Test Event"
}]

Upvotes: 0

Views: 1707

Answers (1)

vineel
vineel

Reputation: 3683

@Ram: There is no problem with the date format. Your JSON response is not in the correct format. It should be in this format

{"Data":[],"Total":55,"AggregateResults":null,"Errors":null}

My Guess is you might have forgotten to call ToDataSourceResult method as shown below

public virtual JsonResult Read([DataSourceRequest] DataSourceRequest request)
        {
            return Json(taskService.GetAll().ToDataSourceResult(request));
        }

I have created raw JsonData with the help of your JSON response. Below is the code snippet I used for testing and it is working. Hope this helps you!!

public ContentResult GetScheduleEvent([DataSourceRequest] DataSourceRequest request)
        {
            //string jsonString = "{\"Data\":[{\"RecurrenceRule\":null, \"RecurrenceException\":null,  \"IsAllDay\":false,  \"Start\":\"Sat Feb 20 2016 01:17:07 GMT-0700 (PDT)\",  \"StartTimezone\":null,  \"End\":\"Sat Feb 20 2016 04:17:07 GMT-0700 (PDT)\",  \"EndTimezone\":null,  \"Title\":\"Test Event\"}],\"Total\":1,\"AggregateResults\":null,\"Errors\":null}";
            string jsonString = "{\"Data\":[{\"RecurrenceRule\":null, \"RecurrenceException\":null,  \"IsAllDay\":true,  \"Start\":\"\\/Date(1455775200000)\\/\",  \"StartTimezone\":null,  \"End\":\"\\/Date(1456034400000)\\/\",  \"EndTimezone\":null,  \"Title\":\"Test Event\"}],\"Total\":1,\"AggregateResults\":null,\"Errors\":null}";
            return new ContentResult { Content = jsonString, ContentType = "application/json" };
        }

Upvotes: 1

Related Questions