Skip to content

Instantly share code, notes, and snippets.

@philippedemaret33
Last active February 25, 2022 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philippedemaret33/0fb80ac6285ddadc628bc32f11c137f2 to your computer and use it in GitHub Desktop.
Save philippedemaret33/0fb80ac6285ddadc628bc32f11c137f2 to your computer and use it in GitHub Desktop.
lookup-grid
/* PersonneController.php */
public function index() {
include(app_path() . '/Classes/phpgrid/jqgrid_dist.php');
// Database Conf
$db_conf = array(
"type" => 'mysqli',
"server" => 'localhost',
"user" => 'em',
"password" => 'em33',
"database" => 'e_m'
);
$g = new \jqgrid($db_conf);
$opt = array();
$opt["rowNum"] = 20; // by default 20
$opt["caption"] = "Les Personnes";
$opt["autowidth"] = true;
$opt["altRows"] = true;
$opt["title"] = "Fiche Info";
$opt["name"] = "information";
$opt["width"] = "50";
$opt["editable"] = true;
$opt["edittype"] = "checkbox"; // render as checkbox
$opt["editoptions"] = array("value" => "Oui:Non"); // with these values "checked_value:unchecked_value"
// $cols[] = $col;
$g->set_options($opt);
$g->table = "personnes";
$g->set_actions(array(
"add" => true,
"edit" => true,
"delete" => true, // allow/disallow delete
"export_pdf" => true,
"export_excel" => true,
"autofilter" => true // show/hide autofilter for search
//"search" => "simple" // show single/multi field search condition (e.g. simple or advance)
)
);
// id
$col = array();
$col["title"] = "Id";
$col["name"] = "id";
$col["width"] = "3";
$col["editable"] = false;
// don't show this column in list, in edit/add mode
$col["hidden"] = true;
$col["editrules"] = array("edithidden" => false);
$cols[] = $col;
// created_at
$col = array();
$col["title"] = "Created";
$col["name"] = "created_at";
$col["width"] = "25";
$col["editable"] = false;
// don't show this column in list, in edit/add mode
$col["hidden"] = true;
$col["editrules"] = array("edithidden" => false);
$cols[] = $col;
// information
$col = array();
$col["title"] = "Fiche Info";
$col["name"] = "information";
$col["width"] = "25";
$col["editable"] = true;
$col["edittype"] = "checkbox"; // render as checkbox
$col["formatter"] = "checkbox";
$col["editoptions"] = array("value" => "Oui:Non"); // with these values "checked_value:unchecked_value"
$cols[] = $col;
// pass the cooked columns to grid, true pour afficher toutes les autres colonnes
$g->set_columns($cols, true);
$out_master = $g->render("list1");
return view('personnes.index', array('phpgrid_output' => $out_master));
}
/* personnes.index.blade.php */
<div class="quote">{{!! $phpgrid_output !!}} </div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment