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!
6 comments:
Thanks for the bug report. I try to fix this issue before the next release :)
Andrea,
Could you post the Css code to make the delete columns looks like yours?
Please.
Eddie
Dear Andrea,
Great feature!
Same like Eddie, could you post the css code to make the delete columns looks like yours?
Thanks
It's this :)
.p4a_table a {
padding:5px;
}
.p4a_table .action{
padding-left:10px;
}
.p4a_table tr:hover td {
background:#4b718a;
}
.p4a_table tr td.action:hover {
background:#c6d3de;
}
.p4a_table tr:hover td a {
color:white;
}
.p4a_table tr td.action:hover {
background:orange;
}
.p4a_table tr td.action:hover a{
color:#0b315a;
text-decoration:none;
}
Dear Andrea,
Thanks a lot!.
It works nicely :-)
Btw, just curious.
How should I add the CSS code?
Should I added it to the ..\p4a\themes\default\screen.css.php? (this is what I did)
Or maybe P4A has some kind of CSS override/adding system?
This is so that every time we upgrade P4A, it won't erase the customized css code.
Thank you.
Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!
Post a Comment