PHP code example of himiklab / yii2-jqgrid-widget
1. Go to this page and download the library: Download himiklab/yii2-jqgrid-widget library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
himiklab / yii2-jqgrid-widget example snippets
use himiklab\jqgrid\actions\JqGridActiveAction;
public function actions()
{
return [
'jqgrid' => [
'class' => JqGridActiveAction::className(),
'model' => Page::className(),
],
];
}
use himiklab\jqgrid\JqGridWidget;
use yii\helpers\Url;
<?= JqGridWidget::widget([
'requestUrl' => Url::to('jqgrid'),
'gridSettings' => [
'colNames' => ['ID', 'Title', 'Author', 'Language'],
'colModel' => [
[
'name' => 'id', 'index' => 'id',
'formatter' => 'integer',
'searchoptions' => [
'searchhidden' => true,
'sopt' => ['eq', 'ne', 'lt', 'le', 'gt', 'ge', 'nu', 'nn'],
],
'hidden' => false, 'editable' => false
],
[
'name' => 'title', 'index' => 'title',
'searchoptions' => [
'searchhidden' => true,
'sopt' => ['cn', 'nc', 'bw', 'bn', 'eq', 'ne', 'ew', 'en', 'nu', 'nn'],
],
'hidden' => false, 'editable' => true
],
[
'name' => 'author', 'index' => 'author',
'searchoptions' => [
'searchhidden' => true,
'sopt' => ['cn', 'nc', 'bw', 'bn', 'eq', 'ne', 'ew', 'en', 'nu', 'nn'],
],
'hidden' => false, 'editable' => true
],
[
'name' => 'language', 'index' => 'language',
'formatter' => 'select',
'stype' => 'select',
'edittype' => 'select',
'searchoptions' => [
'clearSearch' => false,
'searchhidden' => true,
'value' => ':;en:English;ru:Русский;cn:汉语',
'sopt' => ['eq', 'ne', 'nu', 'nn'],
],
'editoptions' => ['value' => [
'en' => 'English',
'ru' => 'Русский',
'cn' => '汉语',
]],
'hidden' => false, 'editable' => true
],
],
'rowNum' => 30,
'rowList' => [30, 60, 90],
'autowidth' => true,
'multiselect' => true,
'multiSort' => true,
'rownumbers' => true,
'viewrecords' => true,
'cmTemplate' => ['autoResizable' => true],
'autoresizeOnLoad' => true,
],
'pagerSettings' => [
'edit' => true,
'add' => true,
'del' => true,
'search' => [
'multipleSearch' => true,
'multipleGroup' => true,
'closeAfterSearch' => true,
'showQuery' => true,
]
],
'enableFilterToolbar' => true,
'enableColumnChooser' => true,
'filterToolbarSettings' => [
'stringResult' => true,
],
])
use app\models\Page;
use himiklab\jqgrid\JqGridHelper;
use himiklab\jqgrid\JqGridWidget;
use yii\helpers\Url;
$columns = [
'id' => ['type' => 'integer',],
'title',
'author',
'language' => [
'type' => 'list',
'data' => Page::getAllLanguages(),
],
'visible' => ['type' => 'boolean',],
];
$columnsIsVisible = ['id', 'title', 'author', 'language', 'visible',];
$columnsIsEditable = ['title', 'author', 'language', 'visible',];
echo JqGridWidget::widget([
'requestUrl' => Url::to('jqgrid'),
'gridSettings' => [
'colNames' => ['ID', 'Title', 'Author', 'Language', 'Visible'],
'colModel' => JqGridHelper::jqgridColModel($columns, $columnsIsVisible, $columnsIsEditable),
'rowNum' => 30,
'rowList' => [30, 60, 90],
'autowidth' => true,
'multiselect' => true,
'multiSort' => true,
'rownumbers' => true,
'viewrecords' => true,
'cmTemplate' => ['autoResizable' => true],
'autoresizeOnLoad' => true,
],
'pagerSettings' => [
'edit' => true,
'add' => true,
'del' => true,
'search' => [
'multipleSearch' => true,
'multipleGroup' => true,
'closeAfterSearch' => true,
'showQuery' => true,
]
],
'enableFilterToolbar' => true,
'enableColumnChooser' => true,
'filterToolbarSettings' => [
'stringResult' => true,
],
])
php composer.phar