Hi, I have searched the forum and seen similar posts, but so far, the responses haven't helped me solve my issue, so I am starting a new topic.
I have a perspective table which is populated with event data from a database table using a named query. I would like a user to be able to approve/deny the events and leave a comment. To do this I have 2 columns. A Boolean, to approve/deny the event, and a string column so approver can leave a comment.
Ideally, I would like to allow the user to go through the entire table updating the two columns and then once they are happy with all the changes, commit all of them to the database in one go.
I have set these as editable columns, however when the cell value is edited, as soon as you click off the cell, the data reverts back to the original value.
Is this because of the binding on the data property of the table?
If so, how do I keep the changes made in the table until I am ready to commit them?
Will I have to commit each cell value change as I go along?
Thanks,
Leigh
@Leigh.shannan, as this is an Ignition question I have moved it from General Discussion to the Ignition forum.
Regarding the problem, I think you need to update the table's data property using the onEditCellCommit event.
You might find it useful to also log the approver's username and approval timestamp.
You have to commit it somewhere, where it will feed back into the table display.
I recommend you create two custom properties, either in the view or in the table. Move the query binding to the first, which I would name raw
, and have it deliver in dataset format. The second, which I would name current
, would have an expression binding that adds any additional columns to raw
needed for managing state. (Or just a property binding to raw
if that suffices.) Finally, bind the table's data prop to current
with an expression/script to jsonify it as needed for your display.
The table's onEditCellCommit
event would update the current
dataset, which would then propagate naturally to the table display.
Your "Save" button would loop through the rows of raw
and current
together, constructing and sending SQL updates where they differ. Then after all updates, refresh the query binding.
{ For bonus points, your jsonification binding could also compare to raw
, adding highlighting styles to edited cells. }
1 Like