2017 © Pedro Peláez
 

library jqgrid

Jqgrid for Laravel 5

image

webmachine/jqgrid

Jqgrid for Laravel 5

  • Tuesday, April 3, 2018
  • by webmachine
  • Repository
  • 2 Watchers
  • 1 Stars
  • 74 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 6 % Grown

The README.md

Jqgrid for Laravel 5

Install

Via Composer, (*1)

``` bash $ composer require webmachine/jqgrid, (*2)


Next, you must install the service provider and facade alias: ```php // config/app.php 'providers' => [ ... Webmachine\Jqgrid\JqgridServiceProvider::class, ]; ... 'aliases' => [ ... 'Jqgrid' => Webmachine\Jqgrid\JqgridFacade::class, ];

Publish, (*3)

``` bash $ php artisan vendor:publish --provider="Webmachine\Jqgrid\JqgridServiceProvider", (*4)


## Usage In your Controller ``` php ... use Webmachine\Jqgrid\JqgridFacade as Jqgrid; class FooController extends Controller { /** * @see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:colmodel_options ColModel API. */ const jqgrid_colmodel = [ [ 'label' => 'Id', 'name' => 'id', 'hidden' => true ], [ 'label' => 'Number', 'name' => 'number', 'searchoptions' => [ 'sopt' => ['bw'] ] ], [ 'label' => 'Name', 'name' => 'name', ], [ 'label' => 'Provider', 'name' => 'provider.name', // relation.fieldname 'relation' => 'FooModel.provider' // ModelName.relation (this relation must exist in your model) ] ]; ... public function index() { ... Jqgrid::add_js_colmodel('foo_table', self::jqgrid_colmodel); // add colmodel columns to render in view return view('foo.index'); ... } ... /** * Generate json response for jqgrid * @return string */ public function datagrid() { Jqgrid::init('foo_table', self::jqgrid_colmodel, self::jqgrid_format()); Jqgrid::get_query()->whereIn('user_id', auth()->user()->id); // add extra query conditions return Jqgrid::datagrid(); } ... /** * Return closure function to format jqgrid columns (optional) * @return function */ private static function jqgrid_format() { return function ($column, $value) { $result = $value; if ($column == 'name') { $result = ucfirst($value); } return $result; }; } }

In your view javascript, (*5)

// foo/index.blade.php
...
<!-- Load Jqgrid scripts in your scripts section -->
{!! Jqgrid::scripts() !!}
...
$('#jqgrid').jqGrid({
    url: '{{ url("foo/datagrid") }}',
    colModel: {!! Jqgrid::js_colmodel() !!}
    ...
});

License

The MIT License (MIT). Please see License File for more information., (*6)

The Versions

03/04 2018

dev-master

9999999-dev

Jqgrid for Laravel 5

  Sources   Download

MIT

The Requires

 

by Avatar webmachine

laravel jqgrid