Perspective Tag Browse Tree

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
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.

1 Like

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

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.

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.

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

@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.

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?

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.

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 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!

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

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

if node.currentValue.quality.isGood:

it does not hide the bad quality tag.

If I use

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.

This is an assignment:

if node.currentValue.quality.isGood = True:

You need a condition:

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

BUT… this will return the exact same value as:

if node.currentValue.quality.isGood:

because isGood is a boolean True/False value.

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:

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

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:

return node.currentValue.quality.isGood()

Wrapping this in an if/else statement is basically doing

if True:
    return True
else:
    return False
1 Like

Thanks for your help everyone! Here is what worked:

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…

1 Like

You can shorten that to

return node.currentValue.quality.isGood() or node.hasChildren()
2 Likes