2rats / yii2-sortable-gridview
Sortable modification of standard Yii2 GridView widget
Package info
github.com/2rats/yii2-sortable-gridview
Type:yii2-extension
pkg:composer/2rats/yii2-sortable-gridview
dev-master
2024-08-11 11:29 UTC
Requires
This package is auto-updated.
Last update: 2026-03-11 14:55:14 UTC
README
Sortable modification of standard Yii2 GridView widget.
Installation
The preferred way to install this extension is through composer.
- Either run
php composer.phar require --prefer-dist "himiklab/yii2-sortable-grid-view-widget" "*"
or add
"himiklab/yii2-sortable-grid-view-widget" : "*"
to the require section of your application's composer.json file.
-
Add to your database new
unsigned intattribute, suchsortOrder. -
Add new behavior in the AR model, for example:
use himiklab\sortablegrid\SortableGridBehavior; public function behaviors() { return [ 'sort' => [ 'class' => SortableGridBehavior::className(), 'sortableAttribute' => 'sortOrder' ], ]; }
- Add action in the controller, for example:
use himiklab\sortablegrid\SortableGridAction; public function actions() { return [ 'sort' => [ 'class' => SortableGridAction::className(), 'modelName' => Model::className(), ], ]; }
Usage
- Use SortableGridView as standard GridView with
sortableActionoption. You can also subscribe to the JS event 'sortableSuccess' generated widget after a successful sorting.