Custom actions – checkbox insert into other table

QuestionsCustom actions – checkbox insert into other table
Mauro asked 6 years ago

I have an issue with custom events.

My goal is to insert into another table two informations:
Serial number (read from the datagrid) and the value of a checkbox

I can show the checkbox on the actual grid but when i change the value nothing is excecuting on the db

 

i use this code

 

$e[“on_update”] = array(“add_client”, null, false);
$g->set_events($e);

function add_client($data)

{
global $grid;
$grid->execute_query(“INSERT INTO `dggs_grid`(`serial`, `app`) VALUES ({$data[“serial”]}”,{$data[“app”]}”) “);

}

$out = $g->render(“list1”);

 

Thank you

4 Answers
Abu Ghufran Staff answered 6 years ago

Event handler $data var usage should be like: 28$data[“params”][“app”]

You can put: phpgrid_error($data); and it will debug $data array in error box.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Mauro answered 6 years ago

Ok, the issue is that he don’t take the params serial (with the debug of the query i can see that he take the value of the checkbox (1) but the value of the serial is empty

 

$col[“name”] = “SERIAL”;

——-

$str = “INSERT INTO dggs_grid (‘serial’,’app’) VALUES ({$data[“params”][“SERIAL”]},{$data[“params”][“app”]})”;

Could you please help me?

 

Mauro answered 6 years ago

With the debug i see that in $data is present only the value of the checkbox and the ID how can i read all other params in the grid?

Thank

Abu Ghufran Staff answered 6 years ago

In normal mode, grid sends all $col[“editable”] = true – columns to update.

In excel mode, it only send ID and changed column to server.

You can refer code of demos/editing/custom-events.php and see how it works.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

4 + 4 =

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?