This is a migrated thread and some comments may be shown as answers.

AppointmentSaving called twice

2 Answers 101 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Margret
Top achievements
Rank 1
Margret asked on 07 Apr 2011, 03:06 PM
Hi,
i'm currently using the AppointmentSaving event of the RadScheduleView for validation.
if the edited or created appointment does not contain the right values a MessageBox should be shown an the appointment should not be saved.

Unfortunatly the MessageBox only shows up for about half a second. The next time i create an appointment the messagebox shows up again, because the AppointmentSaving event is fired again.

As i searched the known bugs, i found that this should already be fixed, but i'm already using the newest dlls and it does not seem to work. Am i doing something wrong?!

thanks in advance!

private void OnKalenderAppointmentSaving( object sender, AppointmentSavingEventArgs e )
{
      var appointment = (SedlakAppointment)e.Appointment;
 
       if( appointment.SelectedUser == null )
       {
           e.Cancel = true
           e.Handled = true;
           this.ViewModel.ShowError( "Cannot create an appointment without user");
       }  
}

2 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 13 Apr 2011, 08:23 AM
Hi Margret,

Please try to cancel the saving of the appointment like this:

private void OnKalenderAppointmentSaving( object  sender, AppointmentSavingEventArgs e )
{
      var appointment = (SedlakAppointment)e.Appointment;
  
       if( appointment.SelectedUser == null )
       {
          e.Cancel = true;          
          (sender as RadScheduleView).Cancel();
          this.ViewModel.ShowError( "Cannot create an appointment without user");
       }  
}

this is needed, because when you just cancel the event, the appointment is still in edit state and the ScheduleView tries to save it later.

Hope this helps. If you have any additional questions, do not hesitate to contact us again.

Best wishes,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Margret
Top achievements
Rank 1
answered on 13 Apr 2011, 09:44 AM
Thanks for your help. Your solution worked almost perfect. Additionally to your solution I had to specify the mainwindow as owner of the messagebox to prevent it from closing immediatly. Afterwards everything worked as expected.
best regards!
Tags
ScheduleView
Asked by
Margret
Top achievements
Rank 1
Answers by
Yana
Telerik team
Margret
Top achievements
Rank 1
Share this question
or