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

Drag and drop in the same gridview

3 Answers 196 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 1
Jack asked on 16 Jul 2012, 07:15 PM
I have a following scenario and try to accomplished by the grid view.

1) User can drag and drop a cell in the grid view and drop it in the same grid view.
2) the value of the dragging cell will switched with value of the dropping cell
3) there are some column should not allow dragging.
4) the drop should be allow only when it's in the same row of dragging cell.

How can I do it by using RadGridView and DragAndDropManager?  It will be great if there sample code similar to my scenario.

Thanks so much

Jack

3 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 19 Jul 2012, 11:23 AM
Hello Jack,

You can easily accomplish the desired behavior using the DragDropManager.

1) User can drag and drop a cell in the grid view and drop it in the same grid view. 
You will have to set DragDropMangers AllowDrag and AllowCapturedDrag properties to true for the GridViewCell elements, and set AllowDrop to true on the GridView itself.

2) the value of the dragging cell will switched with value of the dropping cell 
You can achieve this in the DropHandler by replacing the values in the property under the Destination object and the sender ones.

3) there are some column should not allow dragging.  
You can check the Column of the current cell in the DragInitialized handler and cancel the event if necessary.

4) the drop should be allow only when it's in the same row of dragging cell. 
You can do this by setting the DragEffects to the correct value in the DragOver handler, depending on the destination element.

Hope this helps! 

Regards,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Tomer
Top achievements
Rank 1
answered on 09 Dec 2012, 02:57 PM
Hello Nik,

I am trying to do the same thing. When i am dragging the cell the DragQueryHandler event fires but, when i am dropping 
the cell the event that is suppose to handle the drop doesn't fire.

Do you have an example project? it will be great!

Regards,

Amir 
0
Nick
Telerik team
answered on 10 Dec 2012, 01:00 PM
Hi Amir,

A possible reason for this could be that the cell doesn't have AllowDrop set to true on it. Another possible reason is that the DropQueryHandler does approve the query. 

Note that the RadDragAndDropManager is outdated and we strongly suggest the use of the DragDropManager to achieve Drag and Drop scenarios. You can find various examples on how to achieve certain behavior in our online examples, or in you local copy of our WPF demos.

Hope this helps! 

Regards,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Jack
Top achievements
Rank 1
Answers by
Nick
Telerik team
Tomer
Top achievements
Rank 1
Share this question
or