Drag and drop reorder rows

4 posts, 0 answers
  1. Lowie
    Lowie avatar
    21 posts
    Member since:
    Apr 2013

    Posted 06 May 2013 Link to this post

    Hi there

    For the past day I'm trying to implement drag and drop behavior in the same gridview. I used the demo example to implement this. 
    The events are fired when I click a row and drag, but the row isn't dropped.
    When I debug the code, the DragDropPayloadManager.GetDataFromObject() method returns null in OnRowDragOver and  OnDrop  for the following lines:

    --- OnRowDragOver
    var details = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails;
     
    --- OnDrop
    var draggedItem = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedItem");
    var details = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails;

    Because of that, both events return nothing. 

    Am I missing something?

    Thanks in advance
    Lowie

  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 07 May 2013 Link to this post

    Hello Lowie,

    May I ask you for a bit more information about your scenario? Have you implemented the behavior exactly as shown in the example? May you post your DragInitialize handler? If you set the necessary data in the payload there you should not experience the behavior. 

    Looking forward to hearing from you! 

    All the best,
    Nik
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Lowie
    Lowie avatar
    21 posts
    Member since:
    Apr 2013

    Posted 07 May 2013 Link to this post

    Hi

    I have a RadGridView inside a dockingpanel. I've copied DropIndicationDetails,RowReorderBehavior and the necessary XAML from the example. 
    When I debug OnDragInitialize, the payload is set. But as described in my first post, when I want to retrieve the data, it can't find the data.
    private void OnDragInitialize(object sender, DragInitializeEventArgs e)
            {
                var sourceRow = e.OriginalSource as GridViewRow ?? (e.OriginalSource as FrameworkElement).ParentOfType<GridViewRow>();
                if (sourceRow != null && sourceRow.Name != "PART_RowResizer")
                {
                    DropIndicationDetails details = new DropIndicationDetails();
                    var item = sourceRow.Item;
                    details.CurrentDraggedItem = item;
     
                    IDragPayload dragPayload = DragDropPayloadManager.GeneratePayload(null);
     
                    dragPayload.SetData("DraggedItem", item);
                    dragPayload.SetData("DropDetails", details);
     
                    e.Data = dragPayload;
     
                    e.DragVisual = new DragVisual()
                    {
                        Content = details,
                        ContentTemplate = this.AssociatedObject.Resources["DraggedItemTemplate"] as DataTemplate
                    };
                    e.DragVisualOffset = e.RelativeStartPoint;
                    e.AllowedEffects = DragDropEffects.All;
                }
            }
    
    
    When I check DragEventArgs in OnRowDragOver and OnDrop, the keys in e.Data are different than the ones I've set in OnDragInitialize.

    Thanks in advance
    Lowie
  4. Lowie
    Lowie avatar
    21 posts
    Member since:
    Apr 2013

    Posted 07 May 2013 Link to this post

    I have found the problem.
    It was because the raddocking dragdropmode was set to 'deferred'.
    There are clearly still some problems with the raddocking deffered dragdropmode in combination with other controls.

    Greetings
    Lowie
Back to Top