on_delete event not working

Questionson_delete event not working
Zeead Tanjim asked 8 years ago

Hi There!

I'm using Codeigniter framework and following is the code written in model … rendering works fine, however, on_delete event is not working … would appreciate your expert advice and help in this regards.

<?php

include("asset/phpgrid/config.php");
include("asset/phpgrid/lib/inc/jqgrid_dist.php");

class Staff extends CI_Model {

function getGrid () {
$g = new jqgrid($this->appdata->db_conn());
$e["on_delete"] = array("del_staff", null, false);
$e["on_update"] = array("update_staff", null, true);

$grid["caption"] = "| STAFF INFORMATION |";
$grid["cellEdit"] = false;
$grid["hidegrid"] = false;
$grid["forceFit"] = true;
$grid["autowidth"] = true;
$grid["add_options"] = array('width'=>'600');
$grid["edit_options"] = array('width'=>'600');
$grid["view_options"] = array('width'=>'600');

$col = array();
$col["title"] = "ID";
$col["name"] = "Staff_ID";
$col["align"] = "center";
$col["editable"] = false;
$cols[] = $col;

$col = array();
$col["title"] = "Name";
$col["name"] = "Staff_Name";
$col["editable"] = true;
$col["editoptions"] = array("size"=>75);
$cols[] = $col;

$col = array();
$col["title"] = "Employment Status";
$col["name"] = "Status";
$col["edittype"] = "select";
$col["editable"] = true;
$col["editoptions"] = array("value"=>$this->appdata->ListEmpStat());
$cols[] = $col;

$col = array();
$col["title"] = "NID";
$col["name"] = "NID";
$col["editable"] = true;
$col["editoptions"] = array("size"=>75);
$cols[] = $col;

$col = array();
$col["title"] = "DOB";
$col["name"] = "DOB";
$col["editable"] = true;
$col["formatter"] = "date";
$cols[] = $col;

$col = array();
$col["title"] = "Joining Date";
$col["name"] = "Joining_Date";
$col["editable"] = true;
$col["formatter"] = "date";
$cols[] = $col;

$col = array();
$col["title"] = "Designation";
$col["name"] = "Designation";
$col["editable"] = true;
$col["editoptions"] = array("size"=>75);
$cols[] = $col;

$col = array();
$col["title"] = "Present Address";
$col["name"] = "Present_Address";
$col["editable"] = true;
$col["editoptions"] = array("size"=>75);
$cols[] = $col;

$col = array();
$col["title"] = "Parmanent Address";
$col["name"] = "Parmanent_Address";
$col["editable"] = true;
$col["editoptions"] = array("size"=>75);
$cols[] = $col;

$col = array();
$col["title"] = "Gurantor";
$col["name"] = "Gurantor_Name";
$col["editable"] = true;
$col["editoptions"] = array("size"=>75);
$cols[] = $col;

$col = array();
$col["title"] = "Gurantor Address";
$col["name"] = "Gurantor_Address";
$col["editable"] = false;
$col["editoptions"] = array("size"=>75);
$cols[] = $col;

$col = array();
$col["title"] = "Gurantor Details";
$col["name"] = "Gurantor_Details";
$col["editable"] = true;
$col["editoptions"] = array("size"=>75);
$cols[] = $col;

$col = array();
$col["title"] = "Reference";
$col["name"] = "Reference";
$col["editable"] = true;
$col["editoptions"] = array("size"=>75);
$cols[] = $col;

$col = array();
$col["title"] = "Mobile No";
$col["name"] = "Mobile_No";
$col["editable"] = true;
$col["editoptions"] = array("size"=>75);
$cols[] = $col;

$col = array();
$col["title"] = "Email";
$col["name"] = "Email";
$col["editable"] = true;
$col["editoptions"] = array("size"=>75);
$cols[] = $col;

$col = array();
$col["title"] = "Remarks";
$col["name"] = "Note";
$col["editable"] = true;
$col["editoptions"] = array("size"=>75);
$cols[] = $col;

$g->set_actions(array("rowactions"=>false,
"delete" => true)
);
$g->set_events($e);
$g->set_options($grid);
$g->table = "tbl_staff";
$g->set_columns($cols);

$data['out'] = $g->render("list1");
return $data;
}

function del_staff ($data) {
global $g;
$g->execute_query ("DELETE FROM tbl_staff WHERE Staff_ID = {$data["params"]["Staff_ID"]};");
}
}

1 Answers
Abu Ghufran answered 8 years ago

In callback, the id variable will be:
$data["Staff_ID"]

You can put phpgrid_error($data); before to debug the param as error message.

Your Answer

5 + 10 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?