Treeview component: Detect when expand button is pressed

Hi all!

I want to display a lot of categorized data with a treeview component.

Instead of loading the data all at once, i want to run a script that updates the dataset when one of the expand button is pressed.

Is there a way to detect when the expand button is pressed?

Pressing this:
image
Instead of this:
image

Yes, this is technically possible, by accessing the inner Swing JTree and adding a listener to it:

However, I'm pretty sure just overwriting the dataset won't work - it will immediately collapse all the nodes again.

We don't have any readily available examples of generating a properly lazy tree.
If you don't mind some Swing hacking, you could create your own tree model and populate it with instances of our com.inductiveautomation.ignition.client.util.gui.tree.AbstractLazyLoadingTreeNode class entirely using scripting. That class has an abstract loadChildren() method on it that will be fired to actually initialize each node as it's expanded.

3 Likes

I suggest that you start a new thread and tag it as perspective. Don't mix this one up.