# Perspective Tag Browse Tree

**URL:** <https://forum.inductiveautomation.com/t/perspective-tag-browse-tree/58457>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [April 14, 2022, 7:10am UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree/58457 "2022-04-14T07:10:10Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![deon.korb](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@deon.korb](https://forum.inductiveautomation.com/u/deon.korb)\
**Post date:** [April 14, 2022, 7:10am UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree/58457/1 "2022-04-14T07:10:10Z")

</div>

I saw there is a new Perspective Tag Tree component. I seems a bit barebones.

The nightly release notes reference a forum post, which I could not find. It also appears missing in the documentation.

I am having the following issues with it:  
If `props.root.path` is not specified, it remains loading indefinitely.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/1/51b11ac0c18ce3feeb31e0a29cab01ee9d8d5b9b.png)  
I would expect it to start at a list of tag providers, allowing you to browse from there.

I don’t see a way of filtering at all. I would be handy to be able to filter by names, data type etc.

Is there a way to preserve the tree expansion state when using it in a popup (save to session property)? We use a tag picker to select UDTs for widget configuration and it breaks flow when you start with a flat tag picker every time. It’s likely that you will be referencing tags close together in the tag structure when setting up a new dashboard.

---

<div class="post-metadata">

**Author:** ![jball](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jball/32/11128_2.png) [@jball](https://forum.inductiveautomation.com/u/jball)\
**Post date:** [April 14, 2022, 4:06pm UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree/58457/2 "2022-04-14T16:06:19Z")

</div>

> [@deon.korb](#):
>
> The nightly release notes reference a forum post, which I could not find. It also appears missing in the documentation.

I will reach out to the docs folks to make sure that this is documented ASAP.

> [@deon.korb](#):
>
> I am having the following issues with it:  
> If `props.root.path` is not specified, it remains loading indefinitely.

If no root path is specified, the initial search is made by querying the "Default Provider" assigned in project properties. That is found under the **Project** --\> **Project Properties** menu item (additionally, see the image below). That said, the perpetual loading state is annoying if there is no default provider assigned to the project. I'll open a ticket for this. We'll need to remove the loading display and show an appropriate message.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/3/d3e8cc1e6f7c459df218d50d419c99e135b51bc9.png)

> [@deon.korb](#):
>
> I don’t see a way of filtering at all.

There is an extension function called `filterBrowseNode` that will filter the returned content as you browse. The filter is executed on all content (folders and tags). It can also be paired with the root path to really hone in on a location in your tag structure.

> [@deon.korb](#):
>
> Is there a way to preserve the tree expansion state when using it in a popup (save to session property)?

Currently, there is not. You could dynamically set the root path so it loads at the depth that you'd like to target.

---

<div class="post-metadata">

**Author:** ![jball](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jball/32/11128_2.png) [@jball](https://forum.inductiveautomation.com/u/jball)\
**Post date:** [April 15, 2022, 7:48pm UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree/58457/3 "2022-04-15T19:48:26Z")

</div>

@deon.korb , I edited the “filtering” comment above. I’d forgotten about the extension function. We have docs in the works right now, and this will be fully documented shortly.

---

<div class="post-metadata">

**Author:** ![deon.korb](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@deon.korb](https://forum.inductiveautomation.com/u/deon.korb)\
**Post date:** [April 19, 2022, 12:54pm UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree/58457/4 "2022-04-19T12:54:42Z")

</div>

Thanks for the info. I see the documentation is there now.

The filtering function sounds promising, however I’m struggling to see if it can work for my use case.

Can a global search string be used and the tag browser filter on any child node containing the search string? I.e. only show folders and tags that somewhere in the chain contain XYZ?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 19, 2022, 1:22pm UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree/58457/5 "2022-04-19T13:22:39Z")

</div>

Once you have a filtering function option, you can arrange to pre-browse and cache in project script module. The filter function then asks the cache whether to display any particular path.

---

<div class="post-metadata">

**Author:** ![poresky](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@poresky](https://forum.inductiveautomation.com/u/poresky)\
**Post date:** [August 11, 2022, 7:49pm UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree/58457/6 "2022-08-11T19:49:05Z")

</div>

I am also trying to use this filtering function. I’m struggling to find what the available node attributes are and the [Ignition Java Docs](http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.0-beta/com/inductiveautomation/ignition/common/tags/browsing/NodeDescription.html) only show methods like getAttributes() but not the attributes themselves. I am trying to do something like:

if node.quality == ‘Good’:  
return True  
else:  
return False

but it returns an error that quality is not an attribute. Any help here?

Thank you!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 11, 2022, 8:57pm UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree/58457/7 "2022-08-11T20:57:43Z")

</div>

It would be `node.currentValue.quality.isGood`, though I’m not sure that will do what you actually want.

---

<div class="post-metadata">

**Author:** ![poresky](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@poresky](https://forum.inductiveautomation.com/u/poresky)\
**Post date:** [August 11, 2022, 10:24pm UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree/58457/8 "2022-08-11T22:24:48Z")

</div>

Thanks for this. I have a set of tags, including folders, of good quality except for one. I am testing whether I can hide the bad quality tag.

if I use

```auto
if node.currentValue.quality.isGood:

```

it does not hide the bad quality tag.

If I use

```auto
if node.currentValue.quality.isGood = True:

```

it hides every tag.

Part of my difficulty here is that I don’t know how to run scripts to understand the format because the returned nodes are not in the same scope as, say, the Script Console.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 11, 2022, 10:52pm UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree/58457/9 "2022-08-11T22:52:34Z")

</div>

This is an assignment:

```auto
if node.currentValue.quality.isGood = True:

```

You need a condition:

```auto
if node.currentValue.quality.isGood == True:

```

BUT… this will return the exact same value as:

```auto
if node.currentValue.quality.isGood:

```

because `isGood` is a boolean True/False value.

---

<div class="post-metadata">

**Author:** ![poresky](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@poresky](https://forum.inductiveautomation.com/u/poresky)\
**Post date:** [August 11, 2022, 11:31pm UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree/58457/10 "2022-08-11T23:31:49Z")

</div>

Whoops, mistyped here but I had `==` in my code. Apologies.

Either way, it doesn’t seem to be filtering out the bad quality tags to use that call like so:

```auto
def filterBrowseNode(self, node):
	"""
	Called for each tag before it is displayed in the tag browse tree. Return
	False to exclude the tag from displayed results.

	Arguments:
		self: A reference to the component that is invoking this function.
		node: The tag returned as type NodeBrowseInfo. See the Ignition JavaDocs
		      for usage.
	"""
	
	# This example will filter out any nodes (both Tags and folders included) that do not match the string Ramp.
	if node.currentValue.quality.isGood:
	    return True
	else:
	    return False

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [August 12, 2022, 6:50am UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree/58457/12 "2022-08-12T06:50:03Z")

</div>

I think it should be either `.good` or `.isGood()`.  
Also, you don’t need to put that in an `if/else` statement, you can return it directly:

```python
return node.currentValue.quality.isGood()

```

Wrapping this in an `if/else` statement is basically doing

```python
if True:
    return True
else:
    return False

```

---

<div class="post-metadata">

**Author:** ![poresky](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@poresky](https://forum.inductiveautomation.com/u/poresky)\
**Post date:** [August 16, 2022, 10:47pm UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree/58457/13 "2022-08-16T22:47:24Z")

</div>

Thanks for your help everyone! Here is what worked:

```auto
def filterBrowseNode(self, node):
	"""
	Called for each tag before it is displayed in the tag browse tree. Return
	False to exclude the tag from displayed results.

	Arguments:
		self: A reference to the component that is invoking this function.
		node: The tag returned as type NodeBrowseInfo. See the Ignition JavaDocs
		      for usage.
	"""
	
	# This example will filter out any nodes (both Tags and folders included) that do not match the string Ramp.
	if (node.currentValue.quality.isGood() or node.hasChildren()):
	    return True
	else:
	    return False

```

The “hasChildren” part was necessary to allow the folders to show up properly.

Now to figure out how to do something similar on the tag browser in the Power Chart component…

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [August 17, 2022, 1:48pm UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree/58457/14 "2022-08-17T13:48:57Z")

</div>

You can shorten that to

```python
return node.currentValue.quality.isGood() or node.hasChildren()

```
