Drag and Drop and SchedulerDialog

4 posts, 2 answers
  1. Michael
    Michael avatar
    18 posts
    Member since:
    Aug 2010

    Posted 13 May 2011 Link to this post

    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
  2. Answer
    Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 16 May 2011 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Michael
    Michael avatar
    18 posts
    Member since:
    Aug 2010

    Posted 16 May 2011 Link to this post

    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
  5. Answer
    Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 20 May 2011 Link to this post

    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
Back to Top