Last active
May 19, 2021 08:59
-
-
Save gridphp/8e4c337cf4e5c81771b60a16b28d541b to your computer and use it in GitHub Desktop.
Using subgrid in laravel, https://gridphp.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div style="padding:10px">{!! $phpgrid_output !!}</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
|-------------------------------------------------------------------------- | |
| Web Routes | |
|-------------------------------------------------------------------------- | |
| | |
| Here is where you can register web routes for your application. These | |
| routes are loaded by the RouteServiceProvider within a group which | |
| contains the "web" middleware group. Now create something great! | |
| | |
*/ | |
// Route::get('/', function () { | |
// return view('welcome'); | |
// }); | |
Route::get('/', 'WelcomeController@index'); | |
Route::post('/', 'WelcomeController@index'); | |
Route::get('/indexDetail', 'WelcomeController@indexDetail'); | |
Route::post('/indexDetail', 'WelcomeController@indexDetail'); | |
Auth::routes(); | |
Route::get('/home', 'HomeController@index')->name('home'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="{{ app()->getLocale() }}"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<meta name="csrf-token" content="{{ csrf_token() }}"> | |
<title>Laravel</title> | |
<!-- Fonts --> | |
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css"> | |
<link rel="stylesheet" type="text/css" media="screen" href="js/phpgrid/themes/redmond/jquery-ui.custom.css"></link> | |
<link rel="stylesheet" type="text/css" media="screen" href="js/phpgrid/jqgrid/css/ui.jqgrid.bs.css"></link> | |
<script src="js/phpgrid/jquery.min.js" type="text/javascript"></script> | |
<script src="js/phpgrid/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script> | |
<script src="js/phpgrid/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script> | |
<script src="js/phpgrid/themes/jquery-ui.custom.min.js" type="text/javascript"></script> | |
<script src="http://jqgrid/dev/lib/js/jqgrid/js/src/utils.js" type="text/javascript"></script> | |
<!-- Styles --> | |
<style> | |
html, body { | |
background-color: #fff; | |
color: #636b6f; | |
font-family: 'Raleway', sans-serif; | |
font-weight: 100; | |
height: 100vh; | |
margin: 0; | |
} | |
.full-height { | |
height: 100vh; | |
} | |
.flex-center { | |
align-items: center; | |
display: flex; | |
justify-content: center; | |
} | |
.position-ref { | |
position: relative; | |
} | |
.top-right { | |
position: absolute; | |
right: 10px; | |
top: 18px; | |
} | |
.content { | |
text-align: center; | |
width: 80%; | |
} | |
.title { | |
font-size: 84px; | |
} | |
.links > a { | |
color: #636b6f; | |
padding: 0 25px; | |
font-size: 12px; | |
font-weight: 600; | |
letter-spacing: .1rem; | |
text-decoration: none; | |
text-transform: uppercase; | |
} | |
.m-b-md { | |
margin-bottom: 30px; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="flex-center position-ref full-height"> | |
@if (Route::has('login')) | |
<div class="top-right links"> | |
@auth | |
<a href="{{ url('/home') }}">Home</a> | |
@else | |
<a href="{{ route('login') }}">Login</a> | |
<a href="{{ route('register') }}">Register</a> | |
@endauth | |
</div> | |
@endif | |
<div class="content"> | |
<div class="title m-b-md"> | |
Laravel | |
<div class="quote">{!! $phpgrid_output !!}</div> | |
<script type="text/javascript"> | |
$.ajaxSetup({headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}}); | |
</script> | |
</div> | |
<div class="links"> | |
<a href="https://laravel.com/docs">Documentation</a> | |
<a href="https://laracasts.com">Laracasts</a> | |
<a href="https://laravel-news.com">News</a> | |
<a href="https://forge.laravel.com">Forge</a> | |
<a href="https://github.com/laravel/laravel">GitHub</a> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. | |
| | |
*/ | |
/** | |
* 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); | |
$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); | |
$out = $g->render("list1"); | |
return view('welcome',array('phpgrid_output'=>$out)); | |
} | |
public function add_client() | |
{ | |
phpgrid_error("Callback of Insert"); | |
} | |
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