Expand treeview on hover

1 Answer 338 Views
TreeView
Jimmy
Top achievements
Rank 1
Iron
Jimmy asked on 09 Feb 2022, 06:48 AM

Good morning,

I am using treeview to display a list and it's children underneath. I want to implement the drag and drop functionality, soI can reorder the list.

I have 2 questions regarding the drag and drop functionality

 

1. How do I keep track of the order, to initially save, but to reinstate it, after i revisit the list ?

Right now I keep track of parent Id's per item. But if I want to reorder the children under it's parent .. it always reorders them by Id.

 

2.  I was wondering how do I expand a parent when hovering over a parent in the list

When starting to drag a list item ... I want to insert it into a parent .. the parent just stays closed. Is there  a way to expand the parent on hover?

 

Thank you for the help up front

1 Answer, 1 is accepted

Sort by
0
Svet
Telerik team
answered on 11 Feb 2022, 02:28 PM

Hi Jimmy,

1.

I am not sure that I understand the exact requirement on this point, but if the initial data array that is passed to the TreeView is stored it can be reused at any point in order to re-instantiate the TreeView in its initial order. Please let me know in case such an approach wouldn't be suitable. If that is the case please provide a bit more details on the use-case scenario. Thank you.

2.

The expandNode() and collapseNode() functions could be called to manually expand or collapse an item on the (nodeDrag) event. For this purpose, some custom logic should be implemented to determine when to call these functions. Please see the following example demonstrating how to expand a node manually when dragging:

https://stackblitz.com/edit/angular-9mxntd?file=app/app.component.ts

I will need to further consult with the dedicated TreeView developers as to why the loading spinners of the expanded items aren't removed and will get back to you next week.

Feel free to write back in case further information is required for this case.

Regards,
Svet
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/.

Svet
Telerik team
commented on 14 Feb 2022, 07:39 AM

Hi Jimmy,

The TreeView rebindChildren() method can be called to stop the display of the loading spinners when the children are loaded. Such an approach in this example won't show the loading spinners at all since the used data is local:

https://stackblitz.com/edit/angular-9mxntd-dpklnh?file=app/app.component.ts

I hope this helps.

Jimmy
Top achievements
Rank 1
Iron
commented on 14 Feb 2022, 09:11 AM

Thank you very much, this already has been very helpful.

The only thing not working is the rebindchildren as I am getting an error. Is this a question of library version ?

Property 'rebindChildren' does not exist on type 'TreeViewComponent'
Svet
Telerik team
commented on 15 Feb 2022, 09:55 AM

That is possible. I can suggest updating the TreeView package to its latest to ensure that the latest feature and enhancements are available:

https://www.telerik.com/kendo-angular-ui/components/treeview/changelog/

Tags
TreeView
Asked by
Jimmy
Top achievements
Rank 1
Iron
Answers by
Svet
Telerik team
Share this question
or