Scheduler Resource Binding using DataSource not displaying Employee. Where are the examples? I need an example that doesn't use BindTo. Also where are the Asp.Net Core 2 examples? all are for Asp.net 1
@(Html.Kendo().Scheduler<
SalonWeb.Models.TimeBlock
>()
.Name("scheduler")
.Date(DateTime.Now)
.StartTime(DateTime.Now)
.Height(600)
.MajorTick(60)
.Views(views =>
{
views.DayView();
views.WeekView();
views.MonthView();
})
.Resources(resource =>
{
//reading but not displaying
resource.Add(m => m.Employee) //employee object
.Title("Employee") //descriptive title
.DataTextField("Name") //property in Employee Object
.DataValueField("Id") //property in Employee Object
.DataColorField("Color") //property in Employee Object
.DataSource(ds => ds
.Read("Read", "Employees") //Read function in Employee controller
);
})
.DataSource(d => d
.Model(m => {
m.Id(f => f.Id);
m.Field(f => f.Title).DefaultValue("No title");
m.Field(f => f.Employee);
})
.Read("Read", "TimeBlocks")
.Create("Create", "TimeBlocks")
.Update("Update", "TimeBlocks")
.Destroy("Delete", "TimeBlocks")
)
)
TimeBlock controller
public
async Task<IActionResult> Create([DataSourceRequest] DataSourceRequest request, TimeBlock timeBlock)
{
if
(ModelState.IsValid)
{
_context.Add(timeBlock);
await _context.SaveChangesAsync();
}
return
Json(await
new
[] { timeBlock }.ToDataSourceResultAsync(request, ModelState));
}
Employee Controller
public
async Task<IActionResult> Read([DataSourceRequest] DataSourceRequest request)
{
return
Json(await _context.Employee.ToDataSourceResultAsync(request));
}