Tree View

I want to use a tree view as a menu. Using the Tree View customizer I have set the tooltip to the Window Name and have also set the selectedTooltip to the same window name.

In the event I want to use system.nav.swapTo ( event.source.toolTipText ) to open the selected window.

But I have put a print event.source.toolTipText first to debug and when ever I click on a tree item it prints None. There is no tooTipText.

Any suggestions?

The tooltip is built-in to the component for individual items so it won’t change the tooltip property when your mouse goes over a row. Rather than responding to the tooltip you should use the selected path or index to figure out the window to swap to.

I was hoping to uses a variable stored in the items (Window Name) that way my event on the selection would be very simple. Having to use the Selected Path means that I have to hard code everything into the event. I have about 40 Windows which is not that much but every time you make a change to the Tree View you will need to edit code where if you could pull the Window Name from the item you would never have to change code.

The reason I am doing this is that I will be loading the Tree View from a SQL table. And each Tree Item (in turn Menu Item) will have a Security value attached to the record. That way I can load the Menu with only the items that the person has access to. I will load the Tree View on Logging in.

Ok, so add an additional column to the tree view’s items dataset called WindowName that is a string. You can do that using the dataset viewer. Of course as soon as you add a new column you can no longer use the tree view customizer since it will wipe out your new column once you save it.

Once you have the new column add a dynamic property to the component called WindowName that is a string. Bind the WindowName property to the following expression:try({Root Container.Tree View.data}[{Root Container.Tree View.selectedItem}, "WindowName"], "")So when you select a row with a WindowName set you will see it in the WindowName property otherwise it will be blank.

I am currently working on this myself, however, I am loading the tree dynamically with the ‘system.gui.getWindowNames()’ and building the dataset from there. I have the following code in the mouseClicked event. You do not have to use the selectedTooltip column for this. You can add additional columns to the item list and reference them (like Travis mentioned above). I do this on other windows. Remember to include the full window path.

data = event.source.data selectedItem = event.source.intSelectedItem if selectedItem != -1: window = data.getValueAt(selectedItem,'selectedTooltip') system.nav.swapTo(window)