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

Drag and Drop and SchedulerDialog

3 Answers 209 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 13 May 2011, 04:04 PM
Hi there,

I have the following problem with ScheduleView and Drag and Drop. As recommended, I implemented a custom DragDropBehavior class that inherits from DefaultDragDropBehavior. In here everything works fine. After the "public override void Drop(DragDropState state)" method was called, the new created appointment is passed to the AppointmentCreating event of the ScheduleView. My Problem is that I want to show the scheduler dialog as it would happen if AppointmentCreating event was produced by a doubleclick. Instead of showing the dialog the AppointmentSaving event handler is called immediatly. How can I achieve it that the dialog will be shown? Since I have different IResourceType objects in my scheduler I need the dialog to give the user the possibility to set them correctly.

thanks in advance,

michael

3 Answers, 1 is accepted

Sort by
0
Accepted
Rosi
Telerik team
answered on 16 May 2011, 08:04 AM
Hi Michael,

This is not an easy task and at this stage I cannot suggest you a way to implement it.

A dialog can be open by using the EditAppointment command of RadScheduleView to show the edit appointment dialog. More details about the command are displayed below:

EditAppointment - shows the edit dialog for an appointment. If no parameter is passed it uses the SelectedAppointment of RadScheduleView. By default this command is bound to double click on appointment.


RadScheduleviewCommands.EditAppointment.Execute( editAppointment, radScheduleView);


However to open the dialog you need a reference to RadScheduleView and such reference is not accessible from the behavior.We are sorry for the inconvenience that this causes to you and we will think how to improve similar scenarios for the future releases.

Kind regards,
Rosi
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
Michael
Top achievements
Rank 1
answered on 16 May 2011, 01:52 PM
Hi Rosi,

thanks for your reply. with your information how to call the execute method of the edit an create command correctly I was able to solve this problem. My workaround is not pretty, but it works. My appointments now have a boolean flag to indicate if they were created from drag or not. If the AppointmentCreating was raised by a drag event I simply fire the RadScheduleViewCommands.CreateAppointment.Execute command. The only problem I had after that was that the resources of the appointment were not set correctly anymore if AppointmentCreating was called the second time. To solve that I keep a reference to the appointment and set the resources again. Finally the Dialog appears correctly with two out of 3 resources set correctly. Now the user only has to select the third resource and then can press the OK button of the edit dialog. Here's my implementation of the AppointmentCreating event handler so you and others get a better imagination of this.

private void Scheduler_AppointmentCreating(object sender, AppointmentCreatingEventArgs e) 
     if (m_AppointmentCeatedByDrag != null
     
         foreach (IResource resource in m_AppointmentCeatedByDrag.Resources) 
             e.Appointment.Resources.Add(resource); 
              
         m_AppointmentCeatedByDrag = null
    
           
    SchedulerAppointmentViewModel app = e.Appointment as SchedulerAppointmentViewModel;             
    if (app.IsCreatedFromDrag) 
    
        app.IsCreatedFromDrag = false
        m_AppointmentCeatedByDrag = app; 
        RadScheduleViewCommands.CreateAppointment.Execute(app, this.Scheduler);            
        e.Handled = true;  
        e.Cancel = true;  
        return
    }                
}


Anyway I'm looking forwarding for a more clean solution.

best regards,

michael
0
Accepted
Rosi
Telerik team
answered on 20 May 2011, 08:33 AM
Hello Michael,

I am glad that you resolved the issue by yourself. At this stage I cannot suggest you another way to implement the task.However we will do our best to think about public API that allows similar scenarios to be easily implemented for one of the next versions of the control. The plans for Q2 are already in progress, that is why most probably we will introduce such API for Q3 2011 release,

Regards,
Rosi
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
Tags
ScheduleView
Asked by
Michael
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Michael
Top achievements
Rank 1
Share this question
or