TreeView to TreeView DragDrop with DataConverter

4 posts, 0 answers
  1. Kyle
    Kyle avatar
    3 posts
    Member since:
    Mar 2013

    Posted 20 May 2013 Link to this post

    I have 2 RadTreeView controls, each of the trees has it's own data type. When dragging from TreeView1 to TreeView2, I would like to do a data conversion from type 1 to type 2. Is there an example of using the DataConverter of the DragDropManager to accomplish this? Or can someone point me in the right direction?
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 23 May 2013 Link to this post

    Hi Kyle,

    The DataConverter of the DragDropManager can be used along with behaviors. However, we do not support behaviors for the RadTreeView control yet. This is why you can use the built-in drag&drop logic and modify only the Drop and DragDropCompleted events. The Drop event is fired when you drop an item. In the handler you can turn off the default drag&drop logic by setting the drop action to None (the default value is Move). This can be done with the following code:

    var options = DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as TreeViewDragDropOptions;
                if (options != null)
                {
                    options.DropAction = DropAction.None;
                }
    Furthermore, the DragDropCompleted event is fired after the Drop. This is why you can implement your custom conversion and drop logic in its handler. Please note that you have to check where the user dropped the item and perform actions accordingly.

    For your convenience we implemented this approach in the attached project. Please take a look at it and let us know if it works for you.

    Regards,
    Pavel R. Pavlov
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Kyle
    Kyle avatar
    3 posts
    Member since:
    Mar 2013

    Posted 11 Jun 2013 Link to this post

    Pavel -
    Thank you for the example. It was a great help. Is there a timeline for when behaviors will be added to RadTreeView?
    Kyle
  5. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 14 Jun 2013 Link to this post

    Hello Kyle,

    We plan to spend resources on researching whether it is possible to integrate all available drag and drop behaviors into one. With such behavior we can allow our customers to implement, in an even easier way, drag and drop operations between all our controls.

    However, at the time of writing we can not estimate a time-frame for the release of such behavior.

    Regards,
    Pavel R. Pavlov
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top