Creating an active table based on text change

Hi All,

So, I have a west navigation pane that I want to put an active or “dynamic” tree into. I’m thinking I can populate the tree table with having two custom datasets in my root container, one being the main window dataset with an extra column to define when it should go into the other dataset that the tree view pulls from. the active table should change with changing of text in a label. Anyway, here is my code, and the error its throwing when i try and run it. It allows to save, but crashes when I actually change the label text.

[code]if event.propertyName ==“text”:

table = event.source.parent.getComponent("Table")
test1 = event.source.parent.getComponent("activeWindows")
pyData = system.dataset.toPyDataSet(table)

headers = ["path","text","icon","background","foreground","tooltip","border","selectedText","selectedIcon","selectedBackground","selectedForeground","selectedTooltip","selectedBorder"]
newData = []
for x in range(len(pyData)):
	if (pyData[x][0]== event.source.parent.getComponent("Location").text):
		row = [pyData[x][1],pyData[x][2],pyData[x][3],pyData[x][4],pyData[x][5],pyData[x][6],pyData[x][7],pyData[x][8],pyData[x][9],pyData[x][10],pyData[x][11],pyData[x][12],pyData[x][13]]
		newData.append(row)

test2 = system.dataset.toDataSet(headers,newData)		
test1.data = test2[/code]

and this is throwing this error at runtime:
Traceback (most recent call last):
File “event:propertyChange”, line 15, in
AttributeError: ‘NoneType’ object has no attribute ‘data’

Ignition v7.5.4 (b1206)
Java: Sun Microsystems Inc. 1.6.0_34

any help appreciated!

To add to this, I can remove the .data and it will run, but it wont populate the table, not even with the correct headers in each column. is there a setting I am missing?

test1 is pointing to activeWindows. Try table.data

Hi everyone,

so my first post was a bit dirty and confusing, so I tried to clean up my code and will explain it a bit more in depth and what I want to do.

I have a window with a tree view property and a label who’s text property is tied to another window through the use of a client tag. When the text in the label changes, I want it to change the data in the dataset for the tree view. to do this, In the window root container I have two custom properties datasets named “activeWindows” and “windows.” The tree view “items” dataset is bound to “activeWindows.” The “Windows” dataset is a dataset containing all the loading and color information for each window that you would find in the tree view “items” dataset, as well as one extra column in the front with text/string data that would match the text seen in the text property of the label component.

What I have done is on the label component, I have set an event handler so that when the text property changes, the below code is performed to get the dataset from the “windows” dataset, convert it to a pyDataSet, sort through the rows I need and put the ones i need on a throw-away pydataset newData, convert it back to a dataset, and save it to the “activeWindows” dataset. With the code below, I don’t get any errors, but I also don’t get anything in my “activeWindows” dataset. I don’t even get the dataset column headers.

If there is anything in this code, or any settings that I should be sure to have set so that it works, please let me know. I am stumped as to why this shouldn’t work.

Thanks, Matt

[code]if event.propertyName ==“text”:

allWindows = event.source.parent.getComponent("windows") #Root container dataset containing all windows
filteredWindows = event.source.parent.getComponent("activeWindows") #Root container dataset that should have the filterd windows
labelText = event.source.text #the text from the label that the table should filter with
pyData = system.dataset.toPyDataSet(allWindows)


headers = ["path","text","icon","background","foreground","tooltip","border","selectedText","selectedIcon","selectedBackground","selectedForeground","selectedTooltip","selectedBorder"]
newData = []
for x in range(len(pyData)):
	if (pyData[x][0]== labelText.text):
		row = [pyData[x][1],pyData[x][2],pyData[x][3],pyData[x][4],pyData[x][5],pyData[x][6],pyData[x][7],pyData[x][8],pyData[x][9],pyData[x][10],pyData[x][11],pyData[x][12],pyData[x][13]]
		newData.append(row)

convertedWindows = system.dataset.toDataSet(headers, newData)
filteredWindows = convertedWindows[/code]

try filteredWindows.data = convertedWindows

if not, do you get an errors?
Add print pyData, and print len(pyData) just to make sure they have values.

Cheers,
Chris