how to Drag & drop row from Gridview to GridView??

17 posts, 0 answers
  1. Jin Hyeok Kim
    Jin Hyeok Kim avatar
    4 posts
    Member since:
    Apr 2009

    Posted 16 May 2009 Link to this post

    Hi,

    I try drag & drop function from gridview1 to gridview2 in wpf application. but i don't know
    please help me..

    Thanks.

  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 18 May 2009 Link to this post

    Hi Jin Hyeok Kim,

    One of our customers has already done that. He has posted the code of his drag and drop application here - http://www.telerik.com/community/forums/silverlight/gridview/gridview-draganddrop-selection-problem.aspx
    For your convenience I have used Pablo's code to create a solution that you can easily run - you can find it attached to my reply.

    Best wishes,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jin Hyeok Kim
    Jin Hyeok Kim avatar
    4 posts
    Member since:
    Apr 2009

    Posted 18 May 2009 Link to this post

    hi
    Thanks for your help, but I have a question.
    I know that namespace(Telerik.Windows.Controls.DragDrop) does not exist in WPF.
    Is this sample execution possible even at WPF?
    I execute project in wpf.
  5. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 20 May 2009 Link to this post

    Hi Jin Hyeok Kim,

    Excuse me for sending you the SL drag/drop. The RadGragDropManager is not available for WPF so currently there is no straightforward way of moving rows from one grid to the other. Nevertheless I have created one class called GridDragDrop that implements this functionality.

    You just have to create an instance of the GridDragDrop class and pass it references to two grids. Whenever the user drags a row from one of the grids and drops it on the other the RowDropped event will ve raised, giving you the freedom to remove the row form the first grid and add it to the second one.

    I am sending you a project that demonstrates the GridDragDrop class.
    Hope this helps.

    Greetings,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. StevenDale
    StevenDale avatar
    100 posts
    Member since:
    Apr 2007

    Posted 14 Oct 2009 Link to this post

    I implemented this solution in my project, however my grid has a and the child heirarchy which no longer opens when this solution is in use.

    Thanks,

    Billy Jacobs
  7. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 20 Oct 2009 Link to this post

    Hello Billy Jacobs,

    I'd love to send you a new sample since the one that I have posted here is a bit outdated and now I will be able to get a better result with fewer lines of code. 

    I would really appreciate it if you could share some more information about your scenario so that I do not miss some important detail that might be crucial for your scenario. Some questions that come to my mind are: Is hierarchy used for both source and target grids? What kind of hierarchy is used (Property hierarchy, self-referencing, etc).


    Best wishes,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. StevenDale
    StevenDale avatar
    100 posts
    Member since:
    Apr 2007

    Posted 20 Oct 2009 Link to this post

    Both grids have child hierarchies. Both are property heirarchies. The first list contains a list of employees and the second grid contains a list of jobs. When I drag an employee to a job or a job to a employee I will assign the job to the employee. Also, I want to be able to expand the heirarchy with the left mouse button as well as use the left mouse button to drag and drop.

    Let me know if you need more detail.

    Thanks,

    Billy Jacobs
  9. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 26 Oct 2009 Link to this post

    Hello Billy Jacobs,

    Excuse me for the delay. The sample will be ready tomorrow.


    Kind regards,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  10. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 28 Oct 2009 Link to this post

    Hi Billy Jacobs,

    Here is the sample that I have promised. The sample application contains one class called GridDragDrop which enables the drag and drop between two grids. The sample application demonstrates how this class can be used.

    I hope this will be helpful.
    Once again I am really sorry for the delay.


    All the best,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  11. Kennet
    Kennet avatar
    104 posts
    Member since:
    Jun 2009

    Posted 09 Nov 2009 Link to this post

    Milan do you have an example for Q3 build.

    I using a simple flat collection. I have two grids and need Drag&drop from "Grid #1" to "Grid #2" grid (with insert, so I can drop anywhere on the grid) and drag&drop within the "Grid #2" so I can change position on items. No need to drag&drop from "Grid #2" to "Grid #1" grid.

    /Ken

    *** SOLVED ***
  12. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 12 Nov 2009 Link to this post

    Hello Kennet,

    I will be posting a a blog post on to that topic soon. I will try to do it tomorrow and notify you when the post is public. You will be able to enable the row reorder functionality that with just a few lines of XAML code.


    Sincerely yours,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  13. StevenDale
    StevenDale avatar
    100 posts
    Member since:
    Apr 2007

    Posted 12 Nov 2009 Link to this post

    Hello Milan,

    Thanks for the sample code on the drag and drop. It worked perfectly until I upgraded to Q3 and now I get build errors with the dragdrop objects. I can send you the specific errors if you need but it looks like you are aware of this issue. 

    Could you update the sample to work for Q3?

    Thanks,

    Billy Jacobs
  14. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 17 Nov 2009 Link to this post

    Hi Billy Jacobs,

    I will post the updated sample tomorrow.


    Sincerely yours,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  15. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 18 Nov 2009 Link to this post

    Hi Billy Jacobs,

    Here is the updated version of the project that works with Q3.


    Sincerely yours,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  16. StevenDale
    StevenDale avatar
    100 posts
    Member since:
    Apr 2007

    Posted 12 Mar 2010 Link to this post

    The sample you sent works as is but when I try to use it in my project I get errors when I drag the grid item outside of the grid. 

    The error is when it is trying to capture the mouse rectangle within the telerik framework.
     
    I have Q3 SP2.
     
    I am forced to downgrade to the Q2 sample where it works.
  17. StevenDale
    StevenDale avatar
    100 posts
    Member since:
    Apr 2007

    Posted 09 Aug 2013 Link to this post

    Would it be possible for you to upgrade this example to use the new DragDropManager? The examples provided for drag & drop do not allow me to get the target row and therefore I can't get the datacontext for the target row. I can modify the DragDrop demo to use 2 Grids, but I can't get the row that the drop occurred on nor the object databound to the row. I am not just trying to move the item from one GridView to the other. I am trying to associate the item in one grid to the item in the other grid.

    Thanks,

    Billy Jacobs
  18. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 14 Aug 2013 Link to this post

    Hi Billy,

    Please, refer to these two articles - Enable Row Reordering within two RadGridView-s and Drag and Drop within RadGridView. They provide extensive information on how to accomplish this task. You can check this online demo as well (you can find the same example in your local copy of WPF demos).
     

    Regards,
    Yoan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
UI for WPF is Visual Studio 2017 Ready