Column value in on_delete

QuestionsColumn value in on_delete
shahid asked 5 years ago

$e["on_insert"] = array("add_master", null, true);
$e["on_delete"] = array("delete_master", null, true);

$grid->set_events($e);

function add_master(&$data)
{
//$id = intval($_GET["rowid"]);
//$comp_id = $_GET["comp_id"];
//$data["params"]["branch_id"] = $id; IT WORKS

$data["params"]["comp_id"] = $_SESSION['comp_id']; IT WORKS
phpgrid_error ($data["params"]["branch_name"]);IT WORKS
}
function delete_master(&$data)
{
$check_sql = "SELECT count(*) as c from employee where branch_id = '".$data["params"]["id"]."'";

$rs = mysql_fetch_assoc(mysql_query($check_sql));

//if ($rs["c"] > 0)
// phpgrid_error("This branch can not be deleted as it has employees with it");
phpgrid_error ($data["params"]["branch_name"]); IT SHOWS BLANK !! wHY

I need to get this value in the last line on delete function. but it shows blank instead of value. What is wrong with the code?

7 Answers
Abu Ghufran answered 5 years ago

Current api only passes ROW ID in on_delete callback function.
If you need other data, you can run another select query and fetch the recordset using passed row id.

shahid answered 5 years ago

Thanks for your response.
I hope this rowid is for the same grid for which we are using on delete function?

Abu Ghufran answered 5 years ago

Yes, definitely.

shahid answered 5 years ago

I tried to get rowid on delete but it shows blank.

function delete_master(&$data)
{

phpgrid_error (intval($_GET[rowid]));

}

Abu Ghufran answered 5 years ago

Suppose, you first column name is 'client_id' then you will use $data["client_id"] in on_delete handler to get row id.
Row id is first column value.

shahid answered 5 years ago

I tried the below and it shows blank –
phpgrid_error ($data["params"]["id"]);

shahid answered 5 years ago

it is working now. I removed params and it is working now.

Your Answer

5 + 6 =

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?