![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgK2FMSzX6nFeKgkEKKhYsvofrZnHdPHAIiOylYsy8Tgrm52DoglspD8R0UeLMsa5oDcKgrAOPOtmUKqtG854k1DeV31OrODtuP92ctj1ysCYsGykzN4Qehur2Q25REadh1BP7wcj5fA9-A/s400/p4a_table_delete_row.png)
Doing that with P4A is not hard: you have to add an action col, intercept the afterClick event and then call the db_source deleteRow event. Yet now it's even simpler because we have added the addDeleteRow helper to the P4A core :
$mytable->addDeleteRow();
If you want you can also call the helper with a custom label col and a custom confirmation message:
$mytable->addDeleteRow('Delete Row','Do you want to delete this row?');
You can find this helper in the svn repository or you can copy and past my code in the libraries directory:
<?php
function P4A_Table_addDeleteRow($table, $params)
{
if (isset($params[0])) {
$col_label = $params[0];
} else {
$col_label = 'Delete';
}
if (isset($params[1])) {
$message = $params[1];
} else {
$message = 'Delete current element';
}
$table->addActionCol('delete');
$table->cols->delete->setWidth(150)
->setLabel($col_label)
->requireConfirmation('onClick', $message);
$table->data->intercept($table->cols->delete,'afterClick','deleteRow');
return $table;
}
Happy P4A hacking!