I have just started using the Kendo MVC Schedule component. I can get the schedule to display with data contained in the schedule. But, what I'm having a hard time determining is how to get the information associated with the item selected when the user clicks on an item in the schedule. For example, I'd like to be able to retrieve the title and description fields from my model that I passed to the Schedule object.
I do have the following JS function that is being fired when the user clicks on an object:
function onChange(e) {
var start = e.start;
var end = e.end;
displayMessageModal("Selection between " + start + " and " + end);
}
My MVC code looks as follows:
@(Html.Kendo().Scheduler<LaibeManpower.Entities.EmployeeUnavailabilitySchedule>()
.Name("EmployeeUnavailableSchedule")
.Date(new DateTime(System.DateTime.Now.Ticks))
.Height(800)
.Editable(false)
.Pdf(pdf => pdf
.FileName("Employee Unavailability Schedule.pdf")
.ProxyURL(Url.Action("PdfExportSave", "EmployeeUnavailableSchedule"))
)
.Toolbar(t => t.Pdf())
.Views(views =>
{
views.MonthView();
views.DayView();
})
.Selectable(true)
.Events(events => events.Change("onChange"))
.DataSource(d => d
.Model(m =>
{
m.Id(f => f.RowId);
})
.Read("ReadSchedule", "Employee")
)
)
How do I get other pieces of information contained in the schedule when the user clicks on an item?
Items have uids embedded in their HTML source, which you can pass to the DataSource's getByUid method:
scheduler.element.on("click", ".k-event", function (e) {
var event = scheduler.dataSource.getByUid($(e.currentTarget).attr("data-uid"))
// process your event here
})