I want to let the user to reArrange the displayed records
by making drag and drop between records could any one tell me the first steps to do that
Hello,
I have attached an example of how to drag and drop records from one grid to another, also from one grid to itself.
I had to delete the images to decrease the volume of the project because of limitations.
Alex
great example and works really well except one problem. Using the scroll wheel to scroll up or down the grid changes the displayed record. Its probably only a byref problem. Its easy to reproduce. You just pick up the first record and start scrolling down using the scrollwheel without releasing the record. The "Adorner (preview?") record will change for some reason.
It would be great if you could tell me how to fix this problem
Thanks
Stef
Hello Stef,
Good one, thanks for the feedback. Actually, if you scrolled down without releasing the button, the dropped record is not the same as the dragged. This is easily solved by setting the Virtualization mode to :
RecordContainerGenerationMode="LazyLoad" .
The problem is that when the dragged record is out of scope it is destoyed and replaced by another one.
With Lazy Load the out of scope records are not destroyed. The problem with the Visual preview still remains.
A workaround for that is saving the visual to something that is not dependant on reference ( hidden image,file etc.).
Alex.
Thank you for the sample, but in my opinion the key disadvantage of it is using of right mouse button. I've tried (both in my project and in the sample you provided) to use left button, but neither PreviewMouseMove, nor MouseMove don't seem while LeftButton is pressed, only selection occurs.
Is there any solution to that?
It is going to fire (PreviewMouseMove), but you would have to use PreviewMouseLeftButtonDown/Up event also, because it is being handled with selection of the record/cell.
Originally, I used Right Click just for this reason - not to interfere with the Record selection of the grid.
I don't think I get it. You think it's an acceptable option to be forced to use the right button to drag&drop records?
PreviewMouseMove works on the DataGrid, but it won't on DataRecordPresenter. As soon as the mouse left button is clicked, we do not receive the MouseMove event anymore..
Can't wait till we have better feature parity with the winform ultragrid.
Shrenik,
Thanks for this. The sample looks great. Moreover, you can check out the "official" way of implementing Drag-Drop by handling the built-in events for that. You can find the sample here: http://blogs.infragistics.com/blogs/alex_fidanov/archive/2009/07/28/drag-amp-drop-with-datapresenter-family-controls.aspx
Hi,
Thanks for this sample, Its really good starting point. I found some issue with this sample like:
1. DataRecordPresenter will return null if Field is not editable
2. When we need to drag-drop some times autoscroll also required.
3. LazyLoad is not resolving the issue of disappering Visual.
4. Drop indication...
I have updated your sample. and posting here back for future user benefits.
Attached sample solved all above problem by creating all the fields as editable but not editable :) which can be applied at individual field level.
Regards
Shrenik
Hello Hua,
I believe you meant "can work with left mouse button". I am attaching that sample too (without the images)
Hello Alex,
I got "DragDropXamGrids test.zip" from helpdesk, it works with right mouse button. If your modified copy can work with right mouse button to drag and drop a record in datagrid, please send the copy to me.
Thanks in advance,
Hua