Delete Row from a table

Hi everyone,

I have a table with Edit and Delete buttons. When you click the Delete button, a confirmation popup appears. If you click the OK button in the popup, it should delete the corresponding row from the table.

  1. Delete Button Script: Add the following script to the actionPerformed event of the Delete button. This script will open the confirmation popup when the Delete button is clicked.

I have to add the following script to the actionPerformed event of the OK button in the Local_UNS/Delete_popup view. This script will close the popup and delete the row from the table when the OK button is clicked.

Don't script it on the popup's button.

Instead, make this button send a confirmation message with system.perspective.sendMessage.

Then, put a message handler on the table (right click -> scripts).
In this message handler, use the table's props.selection property to find which row you need to delete.

note: If the data comes from a database, I suggest you use a query to delete the row from the database table, then refresh the perspective table's data with refreshBinding.

note 2: With this method, you can use a generic confirmation popup. make it take a popup_id and message_type (and maybe the confirmation message you want to display in that popup) as parameters, then you can use those parameters to confirm/cancel whatever you want.

3 Likes