Recursive scan for leaf nodes on selected treeview parent nodes

Hello,

I have a treeview populated from a sql query that is only two layers deep. I have the ability to pass a multiselection to a querie’s where clause but I am not able to get the children of a parent node. Do I need to write the recursion in python or is there a built in way to get children when the selected item = -1?

code for pulling multi select values when each child is selected:

tv = event.source.parent.getComponent('tv')


def get_list():
	item_list = []
	if event.source.selectedItem != -1:
		selection = tv.getSelectedItems()		
		for item in selection:
			item_list.append("'"+tv.data.getValueAt(item,"AccCode")+"'")
	else
		print event.source.selectedItem
	return ','.join(item_list)

filter = get_list()
if len(filter) > 0:
	event.source.parent.gl_acc_list = filter
		

I think you’ll need to write your own logic for getting each sub-item of your selection in the tree.

You might not need a recursive solution for getting the children of implicitly defined ‘folder’ parent nodes though.
Just search the dataset for all paths that begin with the selectedPath property of the TV.

Thanks, that is the path I am moving towards.