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

Drag and drop reorder rows

3 Answers 214 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Lowie
Top achievements
Rank 1
Lowie asked on 06 May 2013, 02:33 PM
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

3 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 07 May 2013, 08:33 AM
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.

0
Lowie
Top achievements
Rank 1
answered on 07 May 2013, 08:55 AM
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
0
Lowie
Top achievements
Rank 1
answered on 07 May 2013, 12:29 PM
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
Tags
GridView
Asked by
Lowie
Top achievements
Rank 1
Answers by
Nick
Telerik team
Lowie
Top achievements
Rank 1
Share this question
or