Skip to content

Instantly share code, notes, and snippets.

@gridphp
Last active June 14, 2020 19:51
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 gridphp/749f9e975c1b583768a5aedf2d8c079f to your computer and use it in GitHub Desktop.
Save gridphp/749f9e975c1b583768a5aedf2d8c079f to your computer and use it in GitHub Desktop.
<?php namespace App\Http\Controllers;
class WelcomeController extends Controller {
/*
|--------------------------------------------------------------------------
| Welcome Controller
|--------------------------------------------------------------------------
|
| This controller renders the "marketing page" for the application and
| is configured to only allow guests. Like most of the other sample
| controllers, you are free to modify or remove it as you desire.
|
*/
var $grid;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Show the application welcome screen to the user.
*
* @return Response
*/
public function index()
{
include(app_path() . '\Classes\phpgrid\jqgrid_dist.php');
// Database config file to be passed in phpgrid constructor
$db_conf = array(
"type" => 'mysqli',
"server" => 'localhost',
"user" => 'root',
"password" => '',
"database" => 'griddemo'
);
$g = new \jqgrid($db_conf);
$this->grid = $g;
$opt["caption"] = "Sample Grid";
$opt["subGrid"] = true;
$opt["subgridurl"] = "indexDetail";
$g->set_options($opt);
$g->table = "clients";
$act["import"] = true;
$act["export"] = true;
$g->set_actions($act);
$e["on_insert"] = array("add_client",$this,false);
$g->set_events($e);
// file upload column
$col = array();
$col["title"] = "Note";
$col["name"] = "note";
$col["width"] = "50";
$col["editable"] = true; // this column is editable
$col["edittype"] = "file"; // render as file
$col["upload_dir"] = "temp"; // upload here
$col["editrules"]["ifexist"] = "rename"; // "rename", "override" can also be set
$col["editrules"]["allowedext"] = "png,gif,bmp,jpeg,jpg,doc,xls,docx,xlsx"; // comma separated list of extensions
$col["show"] = array("list"=>false,"edit"=>true,"add"=>true); // only show in add/edit dialog
$cols[] = $col;
$g->set_columns($cols,true);
$out = $g->render("list1");
return view('welcome',array('phpgrid_output'=>$out));
}
public function add_client()
{
phpgrid_error("Callback of Insert:". $this->grid->options["caption"]);
}
public function indexDetail()
{
include(app_path() . '\Classes\phpgrid\jqgrid_dist.php');
// Database config file to be passed in phpgrid constructor
$db_conf = array(
"type" => 'mysqli',
"server" => 'localhost',
"user" => 'root',
"password" => '',
"database" => 'griddemo'
);
$g = new \jqgrid($db_conf);
$opt["caption"] = "";
$opt["height"] = "";
$g->set_options($opt);
$id = intval($_GET["rowid"]);
$g->table = "invheader";
$g->select_command = "SELECT * FROM invheader WHERE client_id = $id";
$out = $g->render("list2");
return view('detail',array('phpgrid_output'=>$out));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment