We are using Kendo-Scheduler in an Asp.net application.
We are having a problem getting events to display in the calendar.
When we use Server Binding, we can see the events display in the calendar as expected. We do the following in our ViewComponent:
public async Task<IViewComponentResult> InvokeAsync()
{
List<TaskViewModel> myTasks = GetItems();
return View(myTasks); //these events display on the calendar successfully
}
However, we need to use Ajax Binding. When we do the following, no data is returned to the DataSource. When we look at scheduler_dataBound() for the data, we can see that no data is returned from the controller. Also the _total = 0
What am I doing wrong in the below? Why is the Server binding working but not the Ajax Binding?
//my.cshtml
@(Html.Kendo().Scheduler<MyApp.Core.ViewModels.TaskViewModel>()
.Name("scheduler")
.Date(new DateTime(2022, 10, 01))
.StartTime(new DateTime(2022, 10, 01, 7, 00, 00))
.Height(600)
.Views(views =>
{
views.MonthView(m => {
m.Selected(true);
m.EventHeight(150);
});
})
.Timezone("Etc/UTC")
.DataSource(d => d
.Model(m =>
{
m.Field(f => f.OwnerID).DefaultValue(1);
m.Field(f => f.Title).DefaultValue("No title");
m.Field(f => f.Description).DefaultValue("no desc");
m.RecurrenceId(f => f.RecurrenceID);
})
.Read("Read", "MyController")
)
.Events(e => {
e.DataBound("scheduler_dataBound");
})
)
<script type="text/javascript">
function scheduler_dataBound(e) {
var data = $("#scheduler").data("kendoScheduler").dataSource;
console.log(data); //Here -> _total=0 and _data has no objects
}
</script>
//My Controller method
public virtual JsonResult Read([DataSourceRequest] DataSourceRequest request)
{
//This is getting called from calendar datasource read
return Json(GetItems().ToDataSourceResult(request)); //Here I am mocking up data
}
//My Mock data
public List<TaskViewModel> GetItems()
{
List<TaskViewModel> list = new List<TaskViewModel>();
list.Add(new TaskViewModel
{
Title = "Event 1",
Start = new DateTime(2022, 10, 1),
End = new DateTime(2022, 10, 1),
Description = "Description 1",
IsAllDay = false,
OwnerID = 1,
TaskID = 1
});
......More data
return list;
}