JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Menu & Tree › iterate through treeitems › Reply To: iterate through treeitems
Hi,
By using const tree = document.querySelector(“smart-tree”) you can get the Tree’s HTML Element instance. Then you get all tree items or tree item groups, you can use tree.querySelectorAll(“smart-tree-item”); or tree.querySelectorAll(“smart-tree-items-group”); You can also query select by ID or CSS class if you set such to your tree items or groups. By having the HTML Elements stored in a variable, you can then use Smart.Tree’s API to add or remove items. I would like to suggest you to look at https://www.htmlelements.com/demos/tree/context-menu/. This example shows how to add or remove tree items dynamically depending on user selection through a context menu.
Best regards,
Peter Stoev
Smart UI Team
https://www.htmlelements.com/