Drag and Drop from a Grid to a Treeview

2 Answers 30 Views
Drag and Drop Grid ListBox ListView TreeView
Hvale
Top achievements
Rank 1
Hvale asked on 06 Dec 2021, 06:03 AM

Hello,

I'm new here and I'm trying to figure out how can I drag and drop from a Grid to a TreeView

I found this example http://dojo.telerik.com/eWIgu/2

It's something like this what I want to do, but in the example I can't put an element in a certain node of the TreeView, I just add elements to the data source. So how can I do that? I need your help

 

PS. I also want to do this with a listbox instead of a grid. That's possible?

  

2 Answers, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 09 Dec 2021, 06:55 AM

Hello,

I will need a little bit more time to review the issue. I will get back to you once I have more information to share.

Thank you for your patience

Regards,
Neli
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Neli
Telerik team
answered on 15 Dec 2021, 07:01 AM

Hello Hvale,

Thank you for your patience.

I would suggest you when a node is dropped in the TreeView to find the closest element with the 'k-item' class. Then you could use the TreeView append method to add the node to the TreeView.

$("#treeview").kendoDropTarget({
         drop: function (e) {   
             ......           
             var treeview = $("#treeview").data("kendoTreeView");
             var node = $(e.target).closest(".k-item");             
             treeview.append({subCategoryName: dataItem.ContactName}, node) 
         }
     });

Here is the modified Dojo example. 

Regards,
Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Hvale
Top achievements
Rank 1
commented on 16 Dec 2021, 08:06 PM

Thank you very much for your reply.

I have another question

I realized that I can't drag and drop the items inside the tree view. I think it's because of the .kendoDropTarget, but is there a way to fix it?

Neli
Telerik team
commented on 21 Dec 2021, 09:38 AM

Hi Hvale,

You could execute the logic in the drop event handler only when the draggable instance that leaves the drop target is different than 'treeview'. Below is an example:

 drop: function (e) {             	
         if($(e.draggable.element).attr('id') != 'treeview'){
               ....
        }
}

Here is the modified Dojo example.

Regards,

Neli

Tags
Drag and Drop Grid ListBox ListView TreeView
Asked by
Hvale
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or