Drag and Drop

2 posts, 0 answers
  1. Rahul
    Rahul avatar
    2 posts
    Member since:
    Oct 2011

    Posted 24 Apr 2013 Link to this post

    Dear Telerik,

    We are using 2013Q1 version of GanttView as per online documentation i have implemented drag and drop functionality

    On xaml inside RadGanttView

    <telerik:RadGanttView.DragDropBehavior>

    <custom:CustomDragDropBehavior />

    </telerik:RadGanttView.DragDropBehavior>

    In My Code-Bind

    public class CustomDragDropBehavior : Telerik.Windows.Controls.GanttView.GanttDragDropBehavior

    {

    protected override void Drop(SchedulingDragDropState state)

    {

     

     

    var task = state.DraggedItem as TabsGanttTask;

    }


    }

    When i drag and drop my task i m not getting update start date time and end date time from above code.

    Could you please advise how to achieve the same.



  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 26 Apr 2013 Link to this post

    Hello,

    When creating custom GanttDragDropBehavior in order to get the new Start and End values you should use the state.DestinationSlot property in the method or call the base Drop() method first and then access them from the updated state.DraggedItem. This is an expected behavior because the base Drop() method sets the new values to the Task.

    The next code snippet shows how to get the new and old Start and End times in the Drop() method with both approaches:
    protected override void Drop(Telerik.Windows.Controls.Scheduling.SchedulingDragDropState state)
    {
        base.Drop(state);
      
        var task = state.DraggedItem as GanttTask;
        var newStart = (DateTime)task.Start;
        var newEnd = (DateTime)task.End;
    }

    or
    protected override void Drop(Telerik.Windows.Controls.Scheduling.SchedulingDragDropState state)
    {
        var slot = state.DestinationSlot;
        var newStart = (DateTime)slot.Start;
        var newEnd = (DateTime)slot.End;
     
        base.Drop(state);
    }

    Hope this is helpful.

    Greetings,
    Vladi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top