# Using Tree view to create a hierarchical structure

**URL:** <https://forum.inductiveautomation.com/t/using-tree-view-to-create-a-hierarchical-structure/95715>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [September 9, 2024, 10:03am UTC](https://forum.inductiveautomation.com/t/using-tree-view-to-create-a-hierarchical-structure/95715 "2024-09-09T10:03:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ajay\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Ajay\_Gupta](https://forum.inductiveautomation.com/u/Ajay_Gupta)\
**Post date:** [September 9, 2024, 10:03am UTC](https://forum.inductiveautomation.com/t/using-tree-view-to-create-a-hierarchical-structure/95715/1 "2024-09-09T10:03:03Z")

</div>

Hi,  
I am trying to create "Equipment Heirarchy" on a perspective screen using Tree view control in the following manner.

When the page loads, one root node with node text "Equipment heirarchies" appears.  
Right clicking "Equipment heirarchies" node, gives a context menu option to "Create a new equipment heirarchy".  
Clicking "Create a new equipment heirarchy" option, opens a popup menu asking the following information-  
1. Name of the Equipment heirarchy  
2. Description  
The popup will have save and cancel options.  
Clicking Save button, adds a child node under root node "Equipment heirarchies".  
Clicking Cancel button, closes the popup window.

Clicking on any node created as a child node of "Equipment heirarchies" node(The root node) should give a context menu option to "Create an Enterprise".  
Clicking "Create an Enterprise" option, opens a popup menu asking the following information-  
1. Name of the Enterprise  
2. Description  
The popup will have save and cancel options.  
Clicking Save button, adds a child node under its parent node.  
Clicking Cancel button, closes the popup window.

In the same manner, Plant, Area, Equipment will be added.

How can I achieve this?  
How can I get a context menu added in the treeview control.

Thanks,  
Ajay

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 9, 2024, 11:38am UTC](https://forum.inductiveautomation.com/t/using-tree-view-to-create-a-hierarchical-structure/95715/2 "2024-09-09T11:38:50Z")

</div>

Look in the Perspective Property Editor under `META.contextMenu`.

Tip: It's the "Tree" component, not "Tree view" or "Tree view control". "View" has a particular meaning in Perspective.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 9, 2024, 11:50am UTC](https://forum.inductiveautomation.com/t/using-tree-view-to-create-a-hierarchical-structure/95715/3 "2024-09-09T11:50:59Z")

</div>

This won't work here as you won't get any comtext. You'll have to call the function [(requestContextMenu)](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/scripting-in-perspective/perspective-component-methods#requesting-or-removing-context-menus) to show it from a right click action, assuming that provides context of what was right clicked.

---

<div class="post-metadata">

**Author:** ![Ajay\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Ajay\_Gupta](https://forum.inductiveautomation.com/u/Ajay_Gupta)\
**Post date:** [September 9, 2024, 12:02pm UTC](https://forum.inductiveautomation.com/t/using-tree-view-to-create-a-hierarchical-structure/95715/4 "2024-09-09T12:02:04Z")

</div>

Thank you for your response.  
Let me try it.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 9, 2024, 12:45pm UTC](https://forum.inductiveautomation.com/t/using-tree-view-to-create-a-hierarchical-structure/95715/5 "2024-09-09T12:45:48Z")

</div>

I don't think you'll be able to do it on right click. You can do it on left click, or left click to select and then use buttons to select the action
