5 Answers, 1 is accepted
Hello, Troy,
RadScheduler offers the AppointmentEditDialogShowing event which is fired just before the edit dialog to be displayed. You have access to the Appointment instance in the AppointmentEditDialogShowingEventArgs. Hence, if you want to load some default values, e.g. Title or Location, you can set the respective properties to the Appointment instance.
public RadForm1()
{
InitializeComponent();
this.radScheduler1.AppointmentEditDialogShowing+=radScheduler1_AppointmentEditDialogShowing;
}
private void radScheduler1_AppointmentEditDialogShowing(object sender, AppointmentEditDialogShowingEventArgs e)
{
e.Appointment.Summary = "Title";
e.Appointment.Location = "Location";
e.Appointment.BackgroundId = 3;
e.Appointment.StatusId = 3;
}
You can check whether you are editing an existing appointment or creating a new by simply checking whether the Appointment is available in the RadScheduler.Appointments collection.
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
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).
Dess,
Thank you for that answer, that gets me part of the way there.
What about the Reminder dropdown?
Also, you said you can tell if its a new or existing appointment by checking the radscheduler.Appointments collection. What exactly would I be checking with/against? Meaning what is the unique id? There is a uniqueId returned on the Appointment on AppointmentEditDialogShowingEventArgs, however that appears to be for that event and not something I can use to compare this appointment with the existing appointments?
In order to determine whether the AppointmentEditDialogShowing event is passing an existing appointment or a new one, you can use the following approach:
private void radScheduler1_AppointmentEditDialogShowing(object sender, AppointmentEditDialogShowingEventArgs e)
{
bool isExistingAppointment=this.radScheduler1.Appointments.Contains(e.Appointment);
}
As to the default value for a reminder, please refer to the following code snippet demonstrating how to access the drop down and initialize with a default value:
private void radScheduler1_AppointmentEditDialogShowing(object sender, AppointmentEditDialogShowingEventArgs e)
{
e.Appointment.Summary = "Title";
e.Appointment.Location = "Location";
e.Appointment.BackgroundId = 3;
e.Appointment.StatusId = 3;
e.AppointmentEditDialog.Shown -= AppointmentEditDialog_Shown;
e.AppointmentEditDialog.Shown += AppointmentEditDialog_Shown;
}
private void AppointmentEditDialog_Shown(object sender, EventArgs e)
{
EditAppointmentDialog dialog = sender as EditAppointmentDialog;
RadDropDownList radDropDownListReminder = dialog.Controls["radDropDownListReminder"] as RadDropDownList;
bool isExistingAppointment = this.radScheduler1.Appointments.Contains(dialog.Appointment);
if (!isExistingAppointment)
{
radDropDownListReminder.SelectedIndex = 1;
}
}
Should you have further questions please let me know.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).
Dess,
First, thank you for all of your help! I was able to do what I needed, almost.
The code you gave me for setting the default reminder, does work. However, I can't get it to work if I've created my own list of reminder times. I really just want a single item in the dropdown and this works.
calScheduledEvents.Reminders.Clear()
Dim
reminderOnTime
As
New
AppointmentReminderInfo(0,
"On Time"
, TimeSpan.FromSeconds(0))
calScheduledEvents.Reminders.Add(reminderOnTime)
However, when I set my own as above, then I am unable to set the selected index as you've shown. I can step through the code and the selected index is always -1, before I set and it after I set it. No exceptions are thrown, etc. Any suggestions on what I'm doing wrong?
Indeed, when you have only one reminder added to RadScheduler, "None" is always displayed and the SelectedIndex remains -1.
In the EditAppointmentDialog there is a ParseTimeSpan method that returns "None" for TimeSpan without any value (0s duration). That is why when this text is set to the reminder drop down, the selection is reset. You should set the Text as well:
private void AppointmentEditDialog_Shown(object sender, EventArgs e)
{
EditAppointmentDialog dialog = sender as EditAppointmentDialog;
RadDropDownList radDropDownListReminder = dialog.Controls["radDropDownListReminder"] as RadDropDownList;
bool isExistingAppointment = this.radScheduler1.Appointments.Contains(dialog.Appointment);
if (!isExistingAppointment)
{
radDropDownListReminder.SelectedIndex = 0;
radDropDownListReminder.Text = "On Time";
}
}
I believe that it would produce the desired result.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.