By default PHPRunner/ASPRunner.NET provide “Delete selected” functionality. In some cases you need to be able to delete records individually. In this tutorial we will show how to add a delete button to each record. We will also show how to make it look as a regular edit/copy/view buttons.
1. Proceed to the List page in Page Designer and insert a button. Move it to one of grid columns. Set button style to “link-button” and choose icon “glyphicon-remove” as appears on a screenshot below.
2. Now lets edit button’s code. We want to ask for a deletion confirmation, delete record and reload the page.
if (confirm("Do you want to delete this record?")) return true; else return false;
In Server event you will need to specify correct table and key column name. In our case table name is categories and key column name is CategoryID.
Server event PHP code:
$record = $button->getCurrentRecord(); $data = array(); $data["CategoryID"] = $record["CategoryID"]; DB::Delete("categories", $data );
Server event C# code:
XVar record = button.getCurrentRecord(); dynamic data = XVar.Array(); data["CategoryID"] = record["CategoryID"]; DB.Delete("categories", data );
Client After event:
This is it. Enjoy!