Cell editing in a table will not be written to the PLC

I try to edit the data in a table, but it will not work.
The column is set to editable in the Table Customizer.
If I make a numeric label with the same tag as in a table cell, then it is possible to edit the value en it’s well written to the PLC.
I use Ignition 7.2.6 and I use a Modicon compact A984-130 as PLC.
I don’t understand what I’m doing wrong ?

In order to use the cell editing feature of the table you have to respond to the cellEdited event handler on the component. The table doesn’t know how to write back to the tag so you have to create a script on the cellEdited event that uses the system.tag.writeToTag function when the appropriate cell has been altered. Check the user manual for more information about the table in appendix a. If you have more questions let us know.

Thanx Travis,

I try it but I have no result.

In the Events handler for the table, I select there “cell/cellEdited” and then I use the Script Editor to write a script.

The following script will not work.

[color=#4040BF]TT = str(event.source.tagpath)
VV = event.newValue
system.tag.writeToTag(TT,VV)[/color]

I get the following error-message :

[color=#BF0000] Traceback (innermost last):
File “event:cellEdited”, line 12, in ?
AttributeError: instance of ‘com.inductiveautomation.factorypmi.application.components.PMITable’ has no attribute ‘tagpath’
[/color]

When I use this script below, that will work, but it will change only the value of that one tag, even if I edit the cell where another tag is placed.

[color=#4000BF]system.tag.writeToTag('V41201-V41260/V41231', event.newValue)[/color]

How can I catch the tag from out a cell and these convert to a string ?

I search and search but I find no solution.
Have you once again a tip ?

Thx.

Well, you just have to know which tag goes with what column. In your script you can do something like:if event.column == 1: system.tag.writeToTag("TagPath1", event.newValue) elif event.column == 2: system.tag.writetoTag("TagPath2", event.newValue)You have a lot of event object properties such as column, row, newValue that you can work with. Remember, the event.column and event.row starts at 0.

Thank you Travis,

That will mean that for every up-datable cell I must write a script in the sense of:

if event.column == 1:
if event.row == 1:
system.tag.writeToTag(“TagPath1”, event.newValue)
elif event.row ==2:
system.tag.writeToTag(“TagPath2”, event.newValue)

elif event.row == 32:
system.tag…

elif event.column == 2:
system.tag.writetoTag(“TagPath2”, event.newValue)

That will be a large, very large script.

Is there really no other solution?
There exist a function system.tag.getTag(??) as parameter must give a string.
But in the help there is no further information about it.

I try to figured out how it works.
Have you any idea ?

How are you populating this table in the first place?

The reason the script is going to be tricky to write is that the Table has no idea where the values in it’s cells came from. (But maybe we can “teach it” depending on your answer to the question above)

@Carl
First I select the table, then I click on the Property bindings in the Property Editor.
Then a window opens with the Property Binding: Tabel.Root Container.Verlichting.data (In this case is Verlichting the name of the table)

There is Cell Update already selected. In the upper field (the table Dataset) there I select a cell. I click on the “+” sign below and in the table “Cell Bindings” I can now fill in the tag.

I select the cell in the column “Value” and then I click on the tag icon and I select the tag I want in the list. A tag looks then like this {V41201-V41260/V41244}.
So for every cell in the table where I want to see the value of a tag I must do that in this way.
Cells in a editable column, I expect that it must be possible to change the value and to write it too the PLC. But that will not.

Thanks

Well, there are two ways to get tag values in the table. The first is using the cell update binding where you link each individual cell of the table to a tag path. In that case you do have to setup a binding for each tag.

The second way is to create a dataset in scripting. Something like:header = ["Col 1", "Col 2"] data = [] data.append([system.tag.getTagValue("V41201-V41260/V41244"), "Another Value"]) data.append(....) # for every row event.source.parent.getComponent("Table").data = system.dataset.toDataSet(header, data)In scripting you can do a loop or use techniques to generate a dataset faster.

Either way when you use the cell editing feature of the table you have to know which cell goes to which tag in order to perform the write back. You can store tag paths in the table along with that values to make the editing more generic. That way you would just hide the tag path column in the table.

Hope this helps.

@Travis,
I don’t now where to write this script ?
I create a table with no columns and no rows. Then I create a Dynamic property of type dataset in the property’s of the table.
But where must I place the script ?
I search in the users manual, but I find no solution.

Thanks.

The best thing to do is to create a dynamic property on the root container called date that is a date/time data type. You can bind the property to the following expression:now(0)When the window opens the date will update to the curent time which causes a propertyChange event. So you can put the script on the propertyChange event of the root container, for example:if event.propertyName == "date": your script....If you want the table to update continually you can set the update rate of the now function, for example now(5000) which is 5 seconds.

You could also create a global script function that returns the dataset. That way you can bind the data property of the table to an expression like:runScript("app.table.generateTable()", 0)Let us know if you need further help.

Hello Travis,
Yes, I need another help.
In created a window Test_1, in the root container of this window I make a dynamic property “Date” of type date. Then I create a property binding of “Date” this is an expression now(2000).
Then in the root container of Test_1 I make a Event handler with property change, and in these script editor there I write the next script:

[color=#0000FF]
if event.propertyName == “date”:
header = [“Licht”, “Burntime”]
data = []
data.append([“Sas”,[system.tag.getTagValue(“V41201-V41260/V41231”)]])
data.append([“Living achter”,[system.tag.getTagValue(“V41201-V41260/V41226”)]])
event.source.Tabelroot = system.dataset.toDataSet(header, data)
[/color]

In the root container of Test_1 I make a dynamic property Tabelroot of type dataset.
I made Tabelroot 2 column’s wide and 2 rows long in Dataset viewer.
I expected now that I could see the data in Tabelroot, but nothing.

I create a table in the window Test_1 also 2 Column’s and 2 rows. I rename this table to “Tabel34”.
How do I get the data to Tabel34 ?
Maybe I do it all wrong ?

I test everything out on a small table, and later on if I understand how its works then I make a bigger table. But at the moment …???

Thank you.

Your last line of code should be:event.source.getComponent("Tableroot").data = system.dataset.toDataSet(header, data)

Travis,

Yes I change the last line, but nothing happens in the good way.
I look with the dataset Viewer at Tabelroot but there is no data to see at all.

I discover that the dynamic property that I have made was with a capital so it must be “Date” .

I get now an error:
[color=#FF0000]
Traceback (innermost last):
File “event:propertyChange”, line 6, in ?
TypeError: readonly class or attribute: data
[/color]

This is my script:
[color=#0000BF]
if event.propertyName == “Date”:
header = [“Licht”, “Burntime”]
data = []
data.append([“Sas”,[system.tag.getTagValue(“V41201-V41260/V41231”)]])
data.append([“Living achter”,[system.tag.getTagValue(“V41201-V41260/V41226”)]])
event.source.getComponent(“Tabelroot”).data = system.dataset.toDataSet(header, data)
[/color]

Have you any idea ?

You have too many square brackets in this line:data.append(["Sas",[system.tag.getTagValue("V41201-V41260/V41231")]])It should be:data.append(["Sas",system.tag.getTagValue("V41201-V41260/V41231")])Change that for both lines and let me know.

@Travis,

I place this problem for a while beside me. Now I picked up again.

My script :
[color=#4000FF]
if event.propertyName == “Date”:
headers = [“Licht”, “Burntime”]
data = []
data.append([“Sas”,system.tag.getTagValue(“V41201-V41260/V41231”)])
data.append([“Living achter”,system.tag.getTagValue(“V41201-V41260/V41226”)])
event.source.getComponent(“Tabel34”).data = system.dataset.toDataSet(headers, data)
[/color]

When I run this, next error pop up:
[color=#FF0040]
Traceback (innermost last):
File “event:propertyChange”, line 8, in ?
java.lang.StackOverflowError
[/color]
Even there is no line 8.
And the table “Tabel34” stays empty.
I try different this to solve this problem, but nothing helps.

Do you have any solution ?

Thanks.

Can you post a screenshot of the error? It might be coming from another propertyChange script?

@Travis,

In the attached file you an see the error.

Thanks.

There are rare restrictions on this forum to attach a file.
Now I hope the file is arrived ?!