Editing a Table with Dataset Data - Scripting Error

Hey
I have a table that is linked to a memory tag with a value "Dataset[7R x 2C]"
This is how the data looks:
image
image

I would like have the user be able to click the "Target" column, add a number.

I have added an event based off this guide:

This is the error I am getting:

Error running action 'component.onEditCellCommit' on site-views/production/production-setup@D/root/Table_0: Traceback (most recent call last): File "<function:runAction>", line 2, in runAction TypeError: 'com.inductiveautomation.ignition.common.BasicDataset' object is unsubscriptable

I have tried this method on the default table that you can drag in from the components pallet & it does work, so this makes me think that doing this with the dataset linked to the data prop is the issue.

How can I solve this problem - I did search the docs and did not find anything so if documentation does exist, apologies, please point me in the right direction

Thanks

It works on the default table because the data is in a JSON format, while you're specified your data is a DataSet. DataSets are indeed unsubscriptable in this manner, and I believe they are also immutable.

Assuming you are reading this data from a tag with a path of [default]ABC/XYZ, try this:

def runAction(self.event):
    # be wary of whitespace differences when copying code from the forums
    tagPath = "[default]ABC/XYZ"
    updatedDataset = system.dataset.setValue(self.props.data, event.row, event.column, event.value)
    system.tag.writeBlocking([tagPath], [updatedDataset])
2 Likes

Hi Cmallonee,

Thanks, this worked!

So I can help myself in the future - Where would I find more information about these functions that you listed

  • system.tag.writeBlocking([tagPath], [updatedDataset])
  • system.dataset.setValue(self.props.data, event.row, event.column, event.value)

Is there some documentation that explains these functions?

Also - It would be good if the Table Documentation had an example of how todo this too

Thanks!

My previous post included a link to the setValue function. I highly recommend you familiarize yourself with the Manual before you continue further.

1 Like

The System Functions toward the bottom of the left-hand navigation is where most of my knowledge comes from.

1 Like

Is this method listed anywhere in the docs? or am i just ment to know how todo this?

Seems like it would be something that a lot of people would use.

It's in the dataset's doc:

https://docs.inductiveautomation.com/display/DOC81/Datasets#Datasets-AlteringaDataset