pozitronik / yii2-grid-helper-asset
js hacks for yii2 grids
Installs: 210
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 2
Language:JavaScript
Requires
- php: >=7.4
Requires (Dev)
- yiisoft/yii2: dev-master
This package is auto-updated.
Last update: 2024-10-29 06:06:25 UTC
README
js hacks for yii2 grids
Installation
The preferred way to install this extension is through composer.
Run
php composer.phar require pozitronik/yii2-grid-helper-asset "dev-master"
or add
"pozitronik/yii2-grid-helper-asset": "dev-master"
to the require section of your composer.json
file.
Usage
<?php /** * @var View $this * ... */ ... use yii\web\View; use app\assets\GridHelperAsset; use yii\helpers\Html; use yii\web\JsExpression; /*preferred usage with kartik grid, but it should work with default grid too*/ use kartik\grid\GridView; ... /*register asset in your view*/ GridHelperAsset::register($this); $id = 'name-for-your-grid'; ?> <?= GridView::widget([ 'id' => $id, /*disable automatic filtering, because we can*/ 'filterOnFocusOut' => false, ... 'toolbar' => [ /*yay, fancy button for manual filtering added. Of course, this handler can be attached anywhere*/ Html::button("<i class='fa fa-filter'></i>", ['onclick' => new JsExpression('setFakeGridFilter("#'.$id.'")'), 'class' => 'btn btn-info']), ] ... ]) ?>