Tree view local folder

Hi, I have a question, I’m seeing the Ignition demo Project and in the document storage windows there is a tree view that display folders from a database and a table that dysplay documents. I wondering if I can display document from a local folder like “c:\reports” and show them in the table, I saw the dataset of the tree view and there is a path column, but I’m no sure it’s posible.

Yes it’s possible. You have to populate the Tree View’s Items dataset. Just as an example, the following script looks for all files and subdirectories under a directory and creates a dataset that is written to the Tree View:[code]import os

treeView = event.source.parent.getComponent(‘Tree View’)
headers = system.dataset.getColumnHeaders(treeView.data)
rows = []
for path, dirs, files in os.walk(’/home/user/downloads’):
for f in files:
newRow = [
path,
f,
“default”,
“color(255,255,255,255)”,
“color(0,0,0,255)”,
“”,
“”,
“”,
“default”,
“color(250,214,138,255)”,
“color(0,0,0,255)”,
“”,
“”
]
rows.append(newRow)
data = system.dataset.toDataSet(headers, rows)
treeView.data = data[/code]In this case you could then carry out whatever action you want whenever the selectedPath property of the Tree View changes. (Note that the selectedItem property is set to -1 when you click on a directory name and an integer >= 0 when you click on a file name.)

You can of course just display directories or just files in a directory as required, just change what you use to populate the dataset.

I’ve using Linux here, so make sure you set your path and the Tree View Separation Character as required for Windows.

Is there an updated version of this? I'm looking to either display the contents of a shared network drive, or using the filepaths in the DB and populate them into the treeview.

This is an ancient Vision post. It predates Perspective. If you're asking about Vision, then sure, the technique above should still work.

If you're asking about Perspective, you should start a new topic. (But the answer is no to local drives. Qualified yes for UNC paths, based on the gateway's access to such.)

Yeah I've configured my gateway conf file so that we can access a network drive, I won't know if it'll work until tomorrow because we can't restart the gateway during production hours. -- Using perspective by the way,

Thank you so much, I'll dig around first to see if I can find a solution, if that fails I'll submit a new topic on how to populate the treeview.