Dear sir,
I have two problems with your otherwise enjoyable software.
- I set an event trigger, to send an email after an insert operation see sourcecode below
$e["on_after_insert"] = array("add_defect", null, true); $grid->set_events($e); function add_defect() { $mail = new PHPMailer; $username = "myusername"; $password = "mypassword"; $body = "Nieuw Defect"; $body = 'Nieuw Defect'+$data["params"]["Boot_Naam"]+" "+$data["params"]["Omschrijving"]; $subject = "Nieuwe defectmelding"; $mail->isSMTP(); $mail->Host = "ssl://smtp.gmail.com"; $mail->SMTPAuth =true; $mail->SMTPSecure = "tls"; $mail->Username = "username"; $mail->Password = "password"; $mail->Port =587; $mail->Body = $body; $mail->SMTPDebug = 3; $mail->From = "[email protected]"; $mail->FromName = "Defectregistratie"; $mail->isHTML(true); $mail->Subject = $subject; $to = "[email protected]"; $mail->addAddress($to); $mail->send(); }
Sending of the email succeeds, save the record also, but the grid shows in the ID field of the saved record (which is an auto increment int(11) field) jqg1 and the grid on the screen freezes, after a refresh everything is ok. But when you then try to store a new record the ID field will show jqg2, etc. Could you please tell me what I am doing wrong.Inline editing is true. - I can’t succeed in disabeling de edit action for the whole grid. It must only be possible to add records. I have set all editing options to false and inline editing to true, but I still get the possibility to edit. Rowactions is false.
Thanks a lot for your help,
Jan Bert Ubels
For #1, You need to return JSON result message as well to avoid error on grid.
For example, your PK of grid is client_id, then:
function add_defects($data) { $insert_id = $data["client_id"]; // it will hold newly inserted id ... $res = array("id" => $insert_id, "success" => true); echo json_encode($res); die; }
#2. Set
$g->set_actions(array( ... "edit"=>false, // dialog "rowactions"=>false, // inline ... ) );
If you can tell exactly which edit mode is enabled, i can suggest better.
Hello Abu Ghufran,
Thanks for your answer, it was not the solution but it showed me the right direction. Thanks to these three lines I found in your documentation:
ob_start(); print_r($data); phpgrid_error(ob_get_clean());
I detected, that the the value jqg1 in the ID field was entered by the phpgrid framework. So what I did, I only used your last lines and changed them, so now it was:
$res = array(“id” => "NULL", “success” => true); echo json_encode($res); die;
That worked like a charm,
In regard to my point two, I want that the user only have the possibility to view and add records, so he must not be able to edit or the delete a record. In spite of all the settings I entered (see rows below), it still offers me the possibility to edit a selected row.
// disable all dialogs except edit $grid->navgrid["param"]["edit"] = false; $grid->navgrid["param"]["add"] = false; $grid->navgrid["param"]["del"] = false; $grid->navgrid["param"]["search"] = false; $grid->navgrid["param"]["refresh"] = true; // enable inline editing buttons $grid->set_actions(array( "inline"=>true, "rowactions"=>false ) ); $grid->set_actions(array( "add"=>true, // allow/disallow add "edit"=>false, // allow/disallow edit "delete"=>false, // allow/disallow delete "rowactions"=>false, // show/hide row wise edit/del/save option "autofilter" => true, // show/hide autofilter for search ) );
So some help would me much appreciated.
Thanks.
Regards,
Jan Bert Ubels
If you can tell exactly how it is allowing edit / delete, i can suggest better.
Screenshot & complete code is required.
You can share screenshot on e.g. https://imgur.com
Hello Abu Ghufran,,
Please find the screenshot here: https://1drv.ms/f/s!Au5LLugIsfWCg6cSCMy5QFWX-jP-cQ
As you can see in the red circle, it is still possible to edit. I tried it on the first row, as you can see I succeeded.
Thanks for your help,
Regards,
Jan Bert Ubels
Thanks, that clarified the issue.
I’ve emailed you updated lib which should fix it.