Treeview Drag and Drop from Grid

4 posts, 0 answers
  1. Brian
    Brian avatar
    5 posts
    Member since:
    Apr 2009

    Posted 24 Mar 2015 Link to this post

    I am dragging and dropping from a grid and it is working fine.  I just have one question.

    If I drag from one treeview to another treeview, I can grab a node from one and when I hover over the second treeview, I have the ability to position the node I am dropping in several locations.  I can either drop it on another node, or I can drop it before or after nodes.

    If I drag from a grid, I don't have that ability.  What would I need to do to enable that ability?
  2. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 26 Mar 2015 Link to this post

    Hello Brian,

    To exactly specify where the item will be dropped, you will need to introduce a field that sets the item ordering, and set this field in the data item prior to inserting, based on the drop event handler. You would also need to enforce that the dataSource is sorted by that field.

    If you do not need the ordering field in your business layer (i.e. ordering the items is only meant to serve as feedback for the user), you may pop a status message that the operation was successful.

    Regards,
    Alex Gyoshev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Brian
    Brian avatar
    5 posts
    Member since:
    Apr 2009

    Posted 26 Mar 2015 in reply to Alex Gyoshev Link to this post

    I don't think that is quite what I meant.  If you go to the demo found at http://demos.telerik.com/kendo-ui/treeview/dragdrop and drag a node from one tree to the other (or even if you just drag a node to another spot in the same treeview), you get a little line to show that you can drop a node in front of another node or after another node.  

    But, if I drag from a grid to a treeview, I can only drop on another node.

    I would like the same functionality if I am dragging from a grid as I have when dragging from another tree.
  5. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 30 Mar 2015 Link to this post

    Hello Brian,

    I'm afraid that this is functionality that is specific to the TreeView, as it preserves the ordering of items. You can provide any cues to the user by handling the drag event and determining your action based on the event arguments. You can see how this behavior is implemented in the TreeView at the end of the src/kendo.treeview.js file. There are two types of cues provided -- the drop line and the drop status -- the second can be easily customized via the e.setStatusClass method, and providing additional cues is up to custom code.

    Regards,
    Alex Gyoshev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready