Perspective table delete row

I have a table in Perspective that the client would like to be able to delete entries from. Initially I accomplished this through an onCellEdited script by getting the dataset, deleting the row, and setting the table data equal to the modified dataset, and it worked well. The client has now requested to be able to delete entries with a button, so I used a very similar script, but every time I try to delete the lowest row in the set, it errors the component. I’m not really sure of what the problem may be, as a near identical script worked in the onCellEdited script. Is there something I’m missing here?

In looking at the documentation for dataset.deleteRow, you’re passing an argument of an unexpected type. You’re supplying an object which defines the values of the row, whereas the function deleteRow expects an int index of the row to delete. You’ll need to loop through the dataset to determine which row is selected from the data you have in row.

Hi @cmallonee,

the same delete function i tried to use on button on click event. I am doing 2 events on button click 1) open popup 2) delete the selected row.
I am able to open popup and delete the table but after 10-20sec the deleted row value gets back in table. I am polling off also but dont know why is it happening also i am using Oracle database for query data. My application is to delete the row from view table but now from database.

Please supply your code for the deletion.

I am attaching onclick event code and query binding. The database used is oracle and the date variable used in named query will take data from last 7 days.

You’re deleting the row from the dataset, but that is not the same as deleting it from the database. Your query only selects the data, and since you haven’t removed the row from the database, when the query gets run again, the row “reappears” in the table.

Ignition Dataset is not equal to database table.

When you remove the row from the dataset in your script you need to also remove the row from the database, either through a system.db.runPrepUpdate or a system.db.runNamedQuery.

I dont want to delete the data from database but only from view table data as the operator need to know that the data he has deleted is sent to MES thats why i am doing the delete function. do you have any other solution to notify operator that data is sent or is already being sent

Then don’t use a query binding to populate the table. Its whole purpose is to display data from the database. You will need to script a suitable state machine that initializes an intermediate property once from the database, then all further manipulations work with that property.

So, i need to use named query in session custom property and then use it anywhere but i have date used to filter so will it update the dummy data or i need to do it separately