Thank you @tony-brunsman for your reply.
So basically, if I want to run non-data related code, the only way is to disconnect the connection between the delete button and the dataset, adds an onClick() event handler to run the needed code, then remove the item by $w(‘dataset’).remove() ?