Issue with DragDropService and TreeView

9 posts, 0 answers
  1. Mark
    Mark avatar
    118 posts
    Member since:
    Oct 2014

    Posted 28 Dec 2016 Link to this post

    I am using a RadTreeView and the DragDropService to Drag/Drop of nodes into the same tree at different levels.  The data on the Tree is bound to an object.  Everything is working except, I can't get the tree on my form to show when the dragdrop has completed so I can update the underline table when changes are made. None of the events are firing,   DragDrop, DragEnded, etc.  What am I missing.

    If this has already been discussed, can someone just point me to the thread. I search, but didn't see this anywhere.

    TIA.

  2. Mark
    Mark avatar
    118 posts
    Member since:
    Oct 2014

    Posted 29 Dec 2016 Link to this post

    One other thing, is my DragDropService is custom, based on the one in the examples for the DragDropService.  There has to be a way to tell the service to tell the TreeView to fire it's event when done, I am not sure how it is done.

     

    Thanks

  3. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3198 posts

    Posted 30 Dec 2016 Link to this post

    Hello Mark,

    Thank you for writing.  

    RadTreeView handles the whole drag and drop operation by its TreeViewDragDropService. The PreviewDragOver event allows you to control on what targets the node being dragged can be dropped on. The PreviewDragDrop event allows you to get a handle on all the aspects of the drag and drop operation, the source (drag) tree view, the destination (target) control, as well as the node being dragged. This is where we will initiate the actual physical move of the node(s) from one grid to the target control. Additional information is available in our online documentation: http://docs.telerik.com/devtools/winforms/treeview/drag-and-drop/drag-and-drop-in-bound-mode

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  4. Mark
    Mark avatar
    118 posts
    Member since:
    Oct 2014

    Posted 03 Jan 2017 Link to this post

    I have read and followed the online documentation.  The problem is, in your documentation, in the TreeViewDragDropService.OnPreviewDragDrop method, the overwritten code does not invoke the PreviewDragDrop event.  In the base method of OnPreviewDragDrop, you do invoke the PreviewDragDrop event. So my first thought was just to call the base.OnPreviewDragDrop(e) in the overwritten code. This didn't work to well and for good reason, all my nodes that I wanted moved have already been moved and position the way I wanted them. So, the next step was to manually invoke the PreviewDragDrop event, which I could not access from my derivative class.  So, my next solution was to create the event ("public new event EventHandler<RadDropEventArgs> PreviewDragDrop") in my class and then invoke it. Maybe I was missing something when I write my derivative, can't be sure, but it is modeled off of the code given in the documentation.

     

  5. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3198 posts

    Posted 05 Jan 2017 Link to this post

    Hello Mark, 

    Thank you for writing back. 

    If you perform the basic logic for the OnPreviewDragDrop method, the event will be fired. However, the node will be dropped according to the default logic. That is why it is not called in the referred help article where the custom drop operation is executed. Actually, you don't need to fire the PreviewDragDrop event if you use a custom TreeViewDragDropService. Could you please specify why do you need to fire this event since the whole drop logic is performed in the overridden OnPreviewDragDrop method? Thus, we would be able to think about a suitable solution and assist you further. Thank you.

    Note that the TreeViewElement.DragDropService.Stopped event is suitable for detecting when the drop operation  has finished.

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. Mark
    Mark avatar
    118 posts
    Member since:
    Oct 2014

    Posted 05 Jan 2017 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Dess said:Hello Mark, 

    Thank you for writing back. 

    If you perform the basic logic for the OnPreviewDragDrop method, the event will be fired. However, the node will be dropped according to the default logic. That is why it is not called in the referred help article where the custom drop operation is executed. Actually, you don't need to fire the PreviewDragDrop event if you use a custom TreeViewDragDropService. Could you please specify why do you need to fire this event since the whole drop logic is performed in the overridden OnPreviewDragDrop method? Thus, we would be able to think about a suitable solution and assist you further. Thank you.

    Note that the TreeViewElement.DragDropService.Stopped event is suitable for detecting when the drop operation  has finished.

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.

     

    I understand that if I call the basic logic for the OnPreviewDragDrop method (base.OnPreviewDragDrop(e);) in my custom overwritten code, that the TreeVewElement.DragDropService.PreviewDragDrop event will be fired.  However, I was not doing that, as per your example in the link you shared previously in this thread.

    Also, my assumptions led me to believe that if this event was not firing, why would any of the others fire as well, since my overwritten code was never calling the base logic.  Looking at your help files on line was of little help when creating a custom RadDragDragService class, there is absolutely no documentation about the “PreviewDargDrop, PreviewDragHit, etc” events for the RadDragDropService, so I started making these assumptions.

    However, using the “Stopped” event seems to work, without having to create a new PreviewDragDrop event and having to manually invoke it.

    The reason for needing to know what is going on at the form level, is when the user is done drag/drop items in the list, I need to be able to save that data to our SQL Database.  It is my lack of knowledge of how the entire DragDropService functions that has led to my issue

    With all this said, there is a lot of learning I have been doing both on the .NET C# side of things and the Telerik side of things. 

    Thanks for the help and understanding.

  7. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3198 posts

    Posted 09 Jan 2017 Link to this post

    HeHello Mark, 

    Thank you for writing back. 

    I am glad that the suggested solution suits your requirement. The PreviewDragHint event is fired when you start dragging a node. This allows you to change the default drag hint. As to the PreviewDropTarget event, it is fired when the target element is changed. It is suitable to extract what is target control/element and perform some custom logic before dropping on it. We will update the online documentation in future to include the PreviewDragHint and PreviewDropTarget events. As to the referred help article, I would like to note that in the OnPreviewDragOver of the custom TreeViewDragDropService, the base method is called. That is why the TreeViewElement.DragDropService.PreviewDragOver is fired but the TreeViewElement.DragDropService.PreviewDragDrop event is not.

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  8. Mark
    Mark avatar
    118 posts
    Member since:
    Oct 2014

    Posted 24 Jan 2017 Link to this post

    Thanks for the help on the TreeView and DragDropService.  I had a question related to the RadGrid and DragDropService. Is there a way to get to the DragDropService from the radGrid like we did from the TreeView?

    thanks for the help

     

  9. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3198 posts

    Posted 25 Jan 2017 Link to this post

    Hello Mark, 

    Thank you for writing back. 

    Similar to RadTreeView, RadGridView handles the whole drag and drop operation by its RadGridViewDragDropService. You can refer to the following help article which demonstrates a sample approach how to customize the drag and drop behavior of RadGridView: http://docs.telerik.com/devtools/winforms/gridview/rows/drag-and-drop

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top