I want to group my scheduler by locations and I'm trying to do so by binding my resources to a datasource. But I can't seem to get it to work (the commented out example - where I use a hardcoded example works fine).
EDIT: Have both tried with or without 'read => read.Action'
I am pulling the data from the following actions in the SchedulerController:
@(Html.Kendo().Scheduler<NFFO_MVC4.Models.BookingViewModel>() .Name("Scheduler") .Date(DateTime.Today) .StartTime(DateTime.Today.AddHours(7)) .EndTime(DateTime.Today.AddHours(20)) .Height(600) .Width(2000) .Messages(message => { message.AllDay("Hele dagen"); message.Today("I dag"); }) .Timezone("Europe/Copenhagen") .Views(views => { views.DayView(day => day.Title("Dag")); views.WeekView(week => week.DateHeaderTemplate("<span title='#=kendo.toString(date, 'dddd dd.MMM')#'>#=kendo.toString(date, 'ddd')#</span>").Title("Uge").Selected(true)); views.MonthView(month => month.Title("MÃ¥ned")); views.AgendaView(); }) .Group(group => group.Resources("Lokationer")) .Resources(resource => resource.Add(m => m.LokationId) .Title("Lokation") .Name("Lokationer") .DataTextField("Navn") .DataValueField("Id") .DataSource(ds => ds.Read(read => read.Action("GetLocations", "Scheduler"))))
//.Resources(resource => resource.Add(m => m.LokationId) // .Title("Lokation") // .Name("Lokationer") // .DataTextField("Text") // .DataValueField("Value") // .DataColorField("Color") // .BindTo(new[] { // new { Text = "Parken Stadium", Value = 1, Color = "#6eb3fa" }, // new { Text = "Sportspladsen", Value = 2, Color = "#f58a8a" },})) .DataSource(d => d .Model(m => m.Id(f => f.BookingId)) .Read("GetBookings", "Scheduler") ))I am pulling the data from the following actions in the SchedulerController:
public ActionResult GetBookings([DataSourceRequest] DataSourceRequest request){ IEnumerable<BookingViewModel> bookingViewModels = _db.Bookinger.Select(booking => new BookingViewModel { BookingId = booking.Id, LokationId = booking.Lokation.Id, Title = booking.Aktivitet, Description = booking.Aktivitet + " (" + booking.Forening + ")", Start = booking.Start, End = booking.Slut, IsAllDay = false }); return Json(bookingViewModels.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);}public ActionResult GetLocations([DataSourceRequest] DataSourceRequest request){ return Json(_db.Lokationer.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);}