Select folder in tree view


I’d like to be able to get the path, even if a node isn’t selected. Is this a possibilty?

You can if you know the index into the dataset where the tree view items are stored. In binding you can get any value out of a dataset by doing the follwing:{Root Container.Component.data}[0][1]The first square bracket is for the row index and second for column index.

Sorry, let me explain. What I’m looking for is to tell which folder is selected if it is highlighted. Since the selectedItem property goes to -1, it’s impossible to index it from the dataset.

We can alter the tree to accommodate this, shouldn’t be hard, I’ve made a ticket for it.

Cool! Sorry, Travis, the “hero” monicker goes back to Carl! :laughing:

A couple of things regarding the tree component:

  1. Can I somehow programatically expand the entire tree?
  2. When I tried to change the tree dataset with “updateRow”, it hangs the designer to the point where I have to kill it with Task Manager. I don’t see anything wrong with my code. Has anyone done this successfully? Save your work before you try it. :slight_smile:
  3. Can I somehow set the background of the whole tree container to something besides white? I would like it to blend in with the rest of the components.

Jordan:
Don’t count your chickens before they hatch! The time between ticket creation and ticket resolution isn’t always as quick as you might like. :confused:

Step7:

  1. I’ll see what I can do to get an expandAll() function on the tree.
  2. Why don’t you post the relevant code here? I’ll be the judge if theres something wrong with it :mrgreen:
  3. Yeah, we can add a background color property.

Sorry, I wasn’t on my dev pc when I posted that.

Anyway, here is the code. You can just plop in in the property change script of the standard tree:

if event.propertyName == 'selectedItem':

	item = event.source.selectedItem
	newIcon='Builtin/icons/16/check2.png'
	
	event.source.data = system.dataset.updateRow(event.source.data, item, {'icon':newIcon})

All I’m trying to do is change the default icon when someone clicks on an item (I keep track of what items have been seleceted in a seperate list). When I click on the item, the designer freezes for a few minutes, but if I do a save while it’s in this frozen state, it really does eventually save. But although I’ve waited upwards of 30 minutes, the designer never frees up again and the only way to kill it is in task manager.

[quote=“Carl.Gould”]Jordan:
Don’t count your chickens before they hatch! The time between ticket creation and ticket resolution isn’t always as quick as you might like. :confused:
[/quote]

Oh, believe me, I know! Been there, still there! :laughing: I’ve gone away from the tree view on this project, but keeping it in mind for future ones!

Step7: The problem with that code is that it creates an event loop.

  1. You react to propertyChange of selectedItem
  2. You alter the tree’s data
  3. The tree re-loads itself, which temporarily clears the selection, and then re-selects the previously selected node.
  4. The tree fires a propertyChange event from the selection change. Go to #1.

The solution would be to check and make sure that the row you’re about to update doesn’t already have that icon configured for it.

Also - the tree already has a background color property so I must have misunderstood what you wanted for #3 above.

[quote=“Carl.Gould”]Step7: The problem with that code is that it creates an event loop.

  1. You react to propertyChange of selectedItem
  2. You alter the tree’s data
  3. The tree re-loads itself, which temporarily clears the selection, and then re-selects the previously selected node.
  4. The tree fires a propertyChange event from the selection change. Go to #1.

The solution would be to check and make sure that the row you’re about to update doesn’t already have that icon configured for it.[/quote]

I tried a few things and got it to work when setting the icon the first time, but hung when I wanted to toggle it. For some reason, the property change event is called twice in a row even though the value doesn’t actually change (i.e., I see 8,8,-1,8,8 when logging the selected item). I’ll have to bind the selected item to a dynamic property and key off that instead. I’ll give it a try later.

That said, how about providing a multi-select mode like you do with lists? That would solve this problem, and the tree would behave more like other tree controls.

[quote]
Also - the tree already has a background color property so I must have misunderstood what you wanted for #3 above.[/quote]

Yep, it sure does Too many late nights I guess.

Where are we on this possiblity to tell which folder is selected if it is highlighted, with the selectedItem property?

Yes, the selectedItem does tell you which row is selected. You can call tree.getSelectedItems() in code to see all of the selected items.

By the way, you can programmatically expand or collapse the tree by calling:event.source.parent.getComponent("Tree View").expandAll() event.source.parent.getComponent("Tree View").collapseAll()

I would like to do the same, would you find the solution?