Using the information of a Power Table in a label that is in another window

hello,

I'm trying to get some string in my power table to be shown in a label in an other window than the power table itself. I found out about this https://docs.inductiveautomation.com/display/DOC/Finding+Components+on+Other+Windows
but this isn't working when I use the expression in a label.

You cannot use an expression/property binding to do this. You need scripting. You need to handle the case when the other window is not open.

A better solution is to use Vision Client Tags as a client-wide persistent value, that you can count on whether a particular window is open or not.

1 Like

image
this is my table for example in window 1
and I want to use a parameter in window 2 that shows the text of the number that is being passed by the parameter.

Are you opening window 2 from an action in window 1? If so, use a window parameter. (Window parameters are assigned to a root container custom property of the same name when the window opens. You can then bind your label to that custom property.)

1 Like

No, I have a template with components that all use the parameter of the template. I made a different window where I import a CSV file with the text list that the label has to show. so if I give my template number 4 for example the label has to show the text at number 4.

So a text list is being imported into the power table so I can assign text to a certain value and then I can say in my label expression that if the parameter is 4 that label shows the text of number 4. This is easy when I have the label and power table in the same window but not if the label is being used in an other window.

Sounds like you need to push the selection in window 1 into a client tag, then bind to that client tag in window 2.

1 Like

Am I still able to subtract the data of my power table like in some similar way as this code:
{Root Container.Power Table.data}[{Root Container.Num},"Tekst"]

I have searched some information about client tags and it looks like it is the answer but I don't see them in my designer. I'm using 8.1.23 version.

Make sure you have the Vision workspace open in the designer (having any vision window open should work). Then select Vision Client Tags in the tag browser dropdown pictured below.
image

2 Likes

Aah, thanks!! I will try to see if I can make this work.

The problem I'm facing now is that this code is only available in a certain window:
{Root Container.Power Table.data}[1,"ColumnName"]
The string that is in this path is what I want to pass to my vision client tag so that I can bound that vision client tag to a label in some other window. But using the expression of my vision client tag I'm not able to select my row and column of my power table.

I found a way to make it possible!

try:
	value = system.gui.getWindow('csv file test').getRootContainer().getComponent('Power Table').data.getValueAt(event.source.parent.parent.DiginNumber-1,"Text")
	system.gui.getWindow('Pop-Up window/L4_CM/Digitale Ingang').getRootContainer().getComponent('Label').text = str("<html>"+ value)
except ValueError:
	print "could not proceed"

I have put this code in the button I use to open the window that has the label in it that had to show the text of my power table. Based on the parameter I pass as a row number it grabs the right text for my label.

Where does the table's data come from ?
It may be easier to pull the label's text from the same data source

from a csv file.

Then maybe you could create a dataset client tag from this csv instead of using it to populate the table,
then use that as a common source.
You could bind both the table and the label to that tag, using a lookup expression for the label.

Seems "cleaner" to me than fetching data from another window that may or may not be opened and may or may not contain the expected data.

1 Like

im not able to import my csv file into the dataset of the tag

i think im doing it wrong but how can I import the csv in the data set of that tag

How do you import from the csv into the table ?

with the use of a button. I have created a button that let me select a file and then put it in the power table
like this:

# In this example it is assumed that the CSV file being read was a dataset that was previously exported using system.dataset.toCSV:
# Specify file path
file_path = system.file.openFile("csv")
# Read in the file as a string
data_string = system.file.readFileAsString(file_path)
# Convert the string to a dataset and store in a variable
data = system.dataset.fromCSV(data_string)
# Assign the dataset to a table
event.source.parent.getComponent('Power Table').data = data