I write my codes in html is OK,but when I bind the datasource using javascript,it is not ok.What's wrong with my codes?
**My View:using Meetings_Read is OK,but using javascript is not OK**
@(Html.Kendo().Scheduler<SchedulerCustomViewDemo.Models.SchedulerTest>()
.Name("scheduler")
.Date(new DateTime(2013, 6, 13))
.StartTime(new DateTime(2014, 4, 13, 7, 00, 00))
.Height(600)
.Views(views => {
views.DayView();
views.WeekView(weekView => weekView.Selected(true));
views.MonthView();
views.AgendaView();
views.CustomView("kendo.ui.ToDoView", view => view.Title("To Do").Selected(true));
})
.DataSource(d => d
.Events(e => e.Error("error_handler"))
// .Read("Meetings_Read", "Home")
)
)
**My Javascript:it is not OK**
$.ajax(
{
url: '@Url.Action("Meetings_Read","Home")',
cache: false,
async: true,
success: function (result) {
var scheduler = $("#scheduler").data("kendoScheduler");
var dataSource = new kendo.data.SchedulerDataSource({
data: result.Data
});
scheduler.setDataSource(dataSource);
}
});
**My Model:can bind to the scheduler,but can not show the title**
public class SchedulerTest: ISchedulerEvent
{
public string Description { get; set; }
public DateTime End { get; set; }
public string EndTimezone { get; set; }
public bool IsAllDay { get; set; }
public string RecurrenceException { get; set; }
public string RecurrenceRule { get; set; }
public DateTime Start { get; set; }
public string StartTimezone { get; set; }
public string Title { get; set; }
}
**My Controller:just show the title of everyday in a month**
public virtual JsonResult Meetings_Read([DataSourceRequest] DataSourceRequest request)
{
return Json(meetingService.GetAll().ToDataSourceResult(request));
}
public List<SchedulerTest> GetAll()
{
var firstDate = DateTime.Now.Date.AddDays(1 - DateTime.Now.Day);
var lastDate = firstDate.AddMonths(1);
var schedulerTests= new List<SchedulerTest>();
int i = 0;
for (; firstDate < lastDate; firstDate = firstDate.AddDays(1))
{
schedulerTests.Add(new SchedulerTest
{
Title = firstDate.ToString("yyMMdd") + "abc",
Start = firstDate,
End = firstDate.AddDyas,
});
}
return schedulerTests;
}
**My View:using Meetings_Read is OK,but using javascript is not OK**
@(Html.Kendo().Scheduler<SchedulerCustomViewDemo.Models.SchedulerTest>()
.Name("scheduler")
.Date(new DateTime(2013, 6, 13))
.StartTime(new DateTime(2014, 4, 13, 7, 00, 00))
.Height(600)
.Views(views => {
views.DayView();
views.WeekView(weekView => weekView.Selected(true));
views.MonthView();
views.AgendaView();
views.CustomView("kendo.ui.ToDoView", view => view.Title("To Do").Selected(true));
})
.DataSource(d => d
.Events(e => e.Error("error_handler"))
// .Read("Meetings_Read", "Home")
)
)
**My Javascript:it is not OK**
$.ajax(
{
url: '@Url.Action("Meetings_Read","Home")',
cache: false,
async: true,
success: function (result) {
var scheduler = $("#scheduler").data("kendoScheduler");
var dataSource = new kendo.data.SchedulerDataSource({
data: result.Data
});
scheduler.setDataSource(dataSource);
}
});
**My Model:can bind to the scheduler,but can not show the title**
public class SchedulerTest: ISchedulerEvent
{
public string Description { get; set; }
public DateTime End { get; set; }
public string EndTimezone { get; set; }
public bool IsAllDay { get; set; }
public string RecurrenceException { get; set; }
public string RecurrenceRule { get; set; }
public DateTime Start { get; set; }
public string StartTimezone { get; set; }
public string Title { get; set; }
}
**My Controller:just show the title of everyday in a month**
public virtual JsonResult Meetings_Read([DataSourceRequest] DataSourceRequest request)
{
return Json(meetingService.GetAll().ToDataSourceResult(request));
}
public List<SchedulerTest> GetAll()
{
var firstDate = DateTime.Now.Date.AddDays(1 - DateTime.Now.Day);
var lastDate = firstDate.AddMonths(1);
var schedulerTests= new List<SchedulerTest>();
int i = 0;
for (; firstDate < lastDate; firstDate = firstDate.AddDays(1))
{
schedulerTests.Add(new SchedulerTest
{
Title = firstDate.ToString("yyMMdd") + "abc",
Start = firstDate,
End = firstDate.AddDyas,
});
}
return schedulerTests;
}