Is there a simple way to get the selected appointment in agenda view?
Or is there a way to convert a AgendaAppointmentWrapper to an Appointment?
Grtz and thnxs
Patrick Vossen
2 Answers, 1 is accepted
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Nov 2019, 01:01 PM
Hello, Patrick,
Note that Agenda view in RadScheduler internally uses a RadGridView. If you need to detect the selected events, you need to actually get the selected rows. Each cell contains the respective information from the associated Appointment:
SchedulerAgendaViewElement agendaViewElement = this.radScheduler1.SchedulerElement.ViewElement as SchedulerAgendaViewElement;
RadGridView agendaGrid = agendaViewElement.Grid;
foreach (GridViewRowInfo selectedRow in agendaGrid.SelectedRows)
{
foreach (GridViewCellInfo cell in selectedRow.Cells)
{
Console.WriteLine(cell.ColumnInfo.Name + " " + cell.Value);
}
}
The AgendaAppointmentWrapper has an internal property that stores the Appointment object. Hence, you don't have public access to it. You can use reflection to get it:
SchedulerAgendaViewElement agendaViewElement = this.radScheduler1.SchedulerElement.ViewElement as SchedulerAgendaViewElement;
RadGridView agendaGrid = agendaViewElement.Grid;
foreach (GridViewRowInfo selectedRow in agendaGrid.SelectedRows)
{
AgendaAppointmentWrapper wrapper = selectedRow.DataBoundItem as AgendaAppointmentWrapper;
FieldInfo fi = typeof(AppointmentWrapper).GetField("appointment", BindingFlags.NonPublic | BindingFlags.Instance);
Appointment appointment = fi.GetValue(wrapper) as Appointment;
}
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers.Learn More.