oonne / yii2-sortable-grid-view
Yii2 GridView widget base on jQuery UI sortable widget
Installs: 2 698
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
This package is auto-updated.
Last update: 2025-02-18 18:52:29 UTC
README
Yii2 GridView widget base on jQuery UI sortable widget.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist "oonne/yii2-sortable-grid-view" "*"
or add
"oonne/yii2-sortable-grid-view" : "*"
to the require section of your composer.json
file.
Usage
-
Add to your database new
unsigned int
attribute, suchsequence
. -
Add new behavior in the active record model, for example:
use oonne\sortablegrid\SortableGridBehavior; public function behaviors() { return [ 'sort' => [ 'class' => SortableGridBehavior::className(), 'sortableAttribute' => 'sequence' ], ]; }
- Add action in the controller, for example:
use oonne\sortablegrid\SortableGridAction; public function actions() { return [ 'sort' => [ 'class' => SortableGridAction::className(), 'modelName' => Model::className(), ], ]; }
- Add SortableGridView in the view, for example:
use oonne\sortablegrid\SortableGridView; SortableGridView::widget([ 'dataProvider' => $dataProvider, 'sortableAction' => ['/bannersuper/sort'], 'columns' => [ [ 'class' => 'yii\grid\SerialColumn', 'contentOptions' => ['class' => 'sortable-handle'], ], [ 'attribute' => 'sName', ], ] ])