Hello Abu,
Can you give me on example of how to use model (MVC architecture) in codeigniter ?
Hi,
Demo may take little time. I can guide how to do it. In controller where you define grid object, you can also set:
$e[“on_insert”] = array(“my_model_insert”, $model_user, false);
$g->set_events($e);
Where my_model_insert is function of $model_user model object. 3rd argument of false tells grid not to execute it’s INSERT query and insert processing is done by callback function.
You may also need to return JSON object for grid on insert, update to reflect changes on grid.
https://phpgrid.org/demo/demos/editing/custom-events.phps (line 119)
Thank you Mr Abu; In my controller code : public function index() { $db_conf = array(); $db_conf[\”type\”] = \”mysqli\”; // mysql,oci8(for oracle),mssql,postgres,sybase $db_conf[\”server\”] = \”127.0.0.1\”; $db_conf[\”user\”] = \”root\”; $db_conf[\”password\”] = \”\”; $db_conf[\”database\”] = \”griddemo\”; require_once(\”assets/phpgrid/lib/inc/jqgrid_dist.php\”); $g = new jqgrid($db_conf); $grid = array(); // set table for CRUD operations $grid[\”caption\”] = \”Test CI GRID\”; $grid[\”rowNum\”] = 20;//10,15 — tinggi grid $grid[\”autowidth\”] = true; $grid[\”height\”] = 460; $grid[\”showhidecolumns\”]= true; $e[\”on_data_display\”] = array(\”filter_display\”, null, false); $grid->set_events($e); $g->table = \”client\”; $g->set_options($grid); $data[\’grid\’] = $g->render(\”list1\”); $this->load->view(\’show_grid\’,$data); } Mode code : function filter_display($data) { foreach($data[\”params\”] as &$d) { foreach($d as $k=>$v) $d[$k] = strtoupper($d[$k]); } } I have error : HTTP ERROR 500 null
Thank you Mr Abu;
In my controller code :
public function index()
{
$this->load->model(‘GridModel’);
require_once(“assets/phpgrid/lib/inc/jqgrid_dist.php”);
$g = new jqgrid($db_conf);$grid = array();
// set table for CRUD operations
$grid[“caption”] = “Test CI GRID”;
$grid[“rowNum”] = 20;//10,15 — tinggi grid
$grid[“autowidth”] = true;
$grid[“height”] = 460;
$grid[“showhidecolumns”]= true;$e[on_data_display”] = array(“filter_display”, $GridModel, false);
$grid->set_events($e);$g->set_options($grid);
$g->table = “client”;
$data[‘grid’] = $g->render(“list1”);
$this->load->view(‘show_grid’,$data);
}
In model : GridModel.php
function filter_display($data)
{
foreach($data[“params”] as &$d)
{
foreach($d as $k=>$v)
$d[$k] = strtoupper($d[$k]);
}
}
I have error : HTTP ERROR 500 null