I can't use Events on Laravel5.5.
source
$e["on_insert"] = array("add_kamoku", null, FALSE);
$g->set_events($e);
error messeage.
call_user_func() expects parameter 1 to be a valid callback, function 'add_kamoku' not found or invalid function name
/Users/hirohito/Laravel5/ringi/app/Classes/phpgrid/jqgrid_dist.php#2167
It appears that your function add_kamoku is some class method and not global function.
In that case, you need to pass class name as second param. e.g. if your class name is 'Foo' you need to set:
$e["on_insert"] = array("add_kamoku", "Foo", FALSE);
Thank you.
It solved. A little problem remains.
'jqg'+xx(xx is integer) show in Id column(Primary/autoincrement).
When reloading, It change integer.
You can set:
$opt["reloadedit"] = true;
…
$g->set_options($opt);
It will force reloading after add/edit.
Unfortunately it doesn't work.
My options is follow
$opt=$this->opt_edit('科目一覧');
$g->set_options($opt);
——————————————-
protected function opt_edit($param) {
$opt=array();
$opt["cellEdit"] = true;
$opt["scroll"] = true;
$opt["autowidth"] = true;
$opt["resizable"] = true;
$opt["viewrecords"] = true;
$opt["caption"] = $param;
$opt["actionicon"] = TRUE;
$opt["reloadedit"] = true;
// $opt["toolbar"] = TRUE;
// $opt["toppager"] = TRUE;
return $opt;
}
Can you check if this issue exist on demo: http://phpgrid.org/demo/demos/editing/inline-add.php
If it's working in demo, please compare you code with it.
Hi Abu,
I need to handle on_insert event in a subgrid (laravel) so I add in my public function index_detail(Request $request) following code:
$e[“on_insert”] = array(“add_prestazione”, “App\Http\Controllers\OrdiniController”, true);
$grid->set_events($e);
In the same controller I put my custom code with a test query:
public function add_prestazione($input)
{
global $grid;
$grid->execute_query(“INSERT INTO test VALUES (‘2′,’testo’)”);
but I got this error message in chrome console.
- {message: “Call to a member function execute_query() on null”, exception: “Error”,…}
- exception: “Error“
- file: “C:\xampp\htdocs\sigesc\app\Http\Controllers\OrdiniController.php“
- line: 2169
- message: “Call to a member function execute_query() on null“
- trace: [{file: “C:\xampp\htdocs\sigesc\app\Classes\phpgrid\jqgrid_dist.php”, line: 2594,…},…]
- 0: {file: “C:\xampp\htdocs\sigesc\app\Classes\phpgrid\jqgrid_dist.php”, line: 2594,…}
- class: “App\Http\Controllers\OrdiniController“
- file: “C:\xampp\htdocs\sigesc\app\Classes\phpgrid\jqgrid_dist.php“
- function: “add_prestazione“
- line: 2594
- type: “::“
- 1: {file: “C:\xampp\htdocs\sigesc\app\Http\Controllers\OrdiniController.php”, line: 1586,…}
- class: “jqgrid“
- file: “C:\xampp\htdocs\sigesc\app\Http\Controllers\OrdiniController.php“
- function: “render“
- line: 1586
- type: “->“
- 2: {function: “indexDetail”, class: “App\Http\Controllers\OrdiniController”, type: “->”}
- class: “App\Http\Controllers\OrdiniController“
- function: “indexDetail“
- type: “->“
- 0: {file: “C:\xampp\htdocs\sigesc\app\Classes\phpgrid\jqgrid_dist.php”, line: 2594,…}
Can you help me find where I’m wrong?
Thanks
When you use laravel, inside controller there is no $grid variable which is defined globally. You need to make it controller member variable and access with $this->grid;
Refer this code: https://gist.github.com/749f9e975c1b583768a5aedf2d8c079f
Line 16,47,86