Hello all,
I want to know a 2 things about Ignition perspective table.
- How do I make certain cell ‘editable’ automatically when the table.props.data changes
- I have created a script to write updated values into DB, but not sure if its a safe and standard way.
#1. see the sreenshot
Here when I pull the data, it contains these columns inside it. I want to make column ‘Control SP’ editable so right now I have added this column into table.columns and made ‘editable’ true and its working.
What I want to know is, if I want to make it via ‘value change script’. How do I convert column from v,alue to object. e.g, right now CONTROL SP: 253, and I want to make it like CONTROL SP.value = 253 & CONTROL SP.editable = true.
So everytime new value comes into table.data, it should convert this column into object and add this 2 props within it. How can I make it?
#2. Right now I made table.column[columnIndex].editable = true and when I update a value of any row from that column, it accepts the value with help of onEditCellCommit event and later upon pressing Confirm Edit I write in to DB with following script:
table = self.getSibling("Table")
updatedData = []
j = 0
#pulling updated values from table and putting into a list
for i in range (len(table.props.data)):
updatedData.append(table.props.data[i]['CONTROL SP'])
while j<(len(table.props.data)):
newValue = updatedData[j]
ID = table.props.data[j]['ID']
recipeID = self.getSibling("Dropdown").props.value
params = {}
params['id'] = ID
params['recipeId'] = recipeID
params['newValue'] = newValue
system.db.runNamedQuery('ProjName', 'UpdateQueries/ControlSetpoints', params)
j+=1
table.refreshBinding("props.data")
And I have created a Update named query to update values inside DB. Is this correct way to do it?
########## System Details ##########
- Windows: Windows 10 Pro, 64-Bit
- Ignition: 8.1.0
Thanks in advance!