Andrew Plummer - Design Development Translation

Example 4: Row Deletion

Summary

Often, you will want to allow users to delete entire rows from the database in addition to editing the data itself.

Example

View Example

PHP Code

$tg = new TableGear(array( "database" => array( "username" => "USERNAME", "password" => "PASSWORD", "database" => "DATABASE", "table" => "TABLE" ), "editable" => "all", "sortable" => "all", "loading" => array( "tag" => "img", "attrib" => array( "src" => "/images/icons/loading.gif", "alt" => "Loading...", "class" => "loading" ) ), "allowDelete" => true, "deleteRowLabel" => array( "tag" => "img", "attrib" => array( "src" => "/images/icons/delete.gif", "alt" => "Delete Row" ) ) );

We start by setting the allowDelete option to true. This will output a column with checkbox inputs and labels for browsers without Javascript. TableGear.js will then hide those checkboxes, and use the label as a button to let the user delete the row, so we need to tell TableGear what that button should be. It can just be text, but here we're passing it a GIF to make it look more button-like.