custom events problem

Questionscustom events problem
santosh asked 9 years ago

Hi,

See my code below. When I edit and save the record, my field is not modified.
Can you please help? thanks

$g = new jqgrid();

// set few params
$grid["shrinkToFit"] = false;
$grid["autowidth"] = true; // expand grid to screen width
$g->set_options($grid);

$e["on_update"] = array("update_client", null, true);
$g->set_events($e);

function update_client($data)
{
$str = "UPDATE p_ozone SET modifier='foo'
WHERE id = {$data["id"]}";
mysql_query($str);
}

3 Answers
santosh answered 9 years ago

what I am trying to do is when any field is updated I want another field updated to be updated with a variable from my code. In the above example I am trying to update the field with text 'foo'

Abu Ghufran answered 9 years ago

Your code looks fine. Check that first column name is 'id'. If not, change it to first column name.
You can always check what comes in $data array using:

function update_client($data)
{

// this would show $data in error msg.
ob_start();
print_r($data);
phpgrid_error(ob_get_clean());

$str = "UPDATE p_ozone SET modifier='foo'
WHERE id = {$data["id"]}";
mysql_query($str);
}

Oscar answered 9 years ago

Same issue, when I insert or update a table, I can't get my PK called event_id (first column), in $data array I just obtain jqg1, and if I try again, jqg2 and so on. Please help. Thanks in advance.

Your Answer

17 + 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?