This question is locked. New answers and comments are not allowed.
Hi,
I have created my own factory class based on ISchedulerDialogHostFactory
I use my own dialogs for edit appointment and delete confirmation dialog.
In my delete confirmation dialog i display information about the appointment to be deleted.
I get hold of the appointment by using CurrentAppointment on the ScheduleView control, but that doesn't seem to be all good.
If I select one appointment by clicking on it, then click the delete button on another appointment, CurrentAppointment is still the first appointment I seletced. So just clicking the delete button will not set it as current.
How can I tell which appointment I clicked the delete button on?
Regards,
Håkan
I have created my own factory class based on ISchedulerDialogHostFactory
I use my own dialogs for edit appointment and delete confirmation dialog.
In my delete confirmation dialog i display information about the appointment to be deleted.
I get hold of the appointment by using CurrentAppointment on the ScheduleView control, but that doesn't seem to be all good.
If I select one appointment by clicking on it, then click the delete button on another appointment, CurrentAppointment is still the first appointment I seletced. So just clicking the delete button will not set it as current.
How can I tell which appointment I clicked the delete button on?
Regards,
Håkan
4 Answers, 1 is accepted
0
Hello Håkan,
I guess that you're using ShowDialog event, you can easily get the appointment that is about to be deleted in its handler like this:
Hope this helps.
All the best,
Yana
the Telerik team
I guess that you're using ShowDialog event, you can easily get the appointment that is about to be deleted in its handler like this:
private void ScheduleView_ShowDialog(object sender, ShowDialogEventArgs e){ var confirmDialog = e.DialogViewModel as ConfirmDialogViewModel; if(confirmDialog != null) { var apps = confirmDialog.Appointments as IOccurrence[]; }}Hope this helps.
All the best,
Yana
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
0
Håkan
Top achievements
Rank 1
answered on 01 Sep 2011, 10:52 AM
Hi,
Actually I'm using my own delete dialog so I have a custom SchedulerDialogHostFactory.
The code looks like this:
Actually I'm using my own delete dialog so I have a custom SchedulerDialogHostFactory.
The code looks like this:
public class TimeScheduleWindowFactory : ISchedulerDialogHostFactory { public event EventHandler<WindowClosedEventArgs> EditShiftDialog_Closed; public event EventHandler<WindowClosedEventArgs> DeleteShiftDialog_Closed; private int actorCompanyId; private TermUtility termUtil; public TimeScheduleWindowFactory(int actorCompanyId, TermUtility termUtil) { this.actorCompanyId = actorCompanyId; this.termUtil = termUtil; } public ISchedulerDialogHost CreateNew(ScheduleViewBase scheduleView, DialogType dialogType) { TimeScheduleShift shift = scheduleView.CurrentAppointment as TimeScheduleShift; switch (dialogType) { case DialogType.AppointmentDialog: // Create new AppointmentDialogHost if (shift != null && shift.ActualStart == new DateTime()) { shift.ActualStart = shift.Start; shift.ActualEnd = shift.End; } EditShiftDialog editShiftDialog = new EditShiftDialog(termUtil, shift, actorCompanyId); editShiftDialog.ScheduleView = scheduleView; editShiftDialog.Closed += new EventHandler<WindowClosedEventArgs>(AppointmentDialog_Closed); editShiftDialog.Initialize(); return editShiftDialog; case DialogType.ConfirmationDialog: // Create new ConfirmationDialogHost if (shift != null) { DeleteShiftDialog deleteShiftDialog = new DeleteShiftDialog(termUtil, shift, actorCompanyId); deleteShiftDialog.ScheduleView = scheduleView; deleteShiftDialog.Closed += new EventHandler<WindowClosedEventArgs>(ConfirmationDialog_Closed); return deleteShiftDialog; } break; case DialogType.RecurrenceChoiceDialog: // Create new RecurrenceChoiceDialogHost //throw new NotImplementedException(); break; case DialogType.RecurrenceDialog: // Create new RecurrenceDialogHost //throw new NotImplementedException(); break; default: //throw new NotImplementedException(); break; } return null; } private void AppointmentDialog_Closed(object sender, WindowClosedEventArgs e) { if (EditShiftDialog_Closed != null) EditShiftDialog_Closed(sender, e); } private void ConfirmationDialog_Closed(object sender, WindowClosedEventArgs e) { if (DeleteShiftDialog_Closed != null) DeleteShiftDialog_Closed(sender, e); } }0
Accepted
Hello Håkan,
I'm sorry I missed that.
The CreateNew method in the SchedulerDialogHostFactory is called too early, that's why you cannot get the appointment which is about to be deleted at this stage. We're setting the DataContext of the dialog ( which contains all the needed information ) later, still before the dialog is opened.
I would suggest to subscribe to Loaded event of the dialog and cast its DataContext to ConfirmDialogViewModel, the needed appointment can be reached through its Appointments property.
Please try it and let us know whether it helps.
Best wishes,
Yana
the Telerik team
I'm sorry I missed that.
The CreateNew method in the SchedulerDialogHostFactory is called too early, that's why you cannot get the appointment which is about to be deleted at this stage. We're setting the DataContext of the dialog ( which contains all the needed information ) later, still before the dialog is opened.
I would suggest to subscribe to Loaded event of the dialog and cast its DataContext to ConfirmDialogViewModel, the needed appointment can be reached through its Appointments property.
Please try it and let us know whether it helps.
Best wishes,
Yana
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
0
Håkan
Top achievements
Rank 1
answered on 20 Sep 2011, 09:59 AM
Thanks Yana, that did the trick!
Regards,
Håkan
Regards,
Håkan