handysolver / yii2-sortable-list-view-widget
Sortable modification of standard Yii2 ListView widget
Installs: 939
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
pkg:composer/handysolver/yii2-sortable-list-view-widget
Requires
This package is not auto-updated.
Last update: 2025-10-23 11:57:33 UTC
README
Sortable modification of standard Yii2 ListView widget.
Credits
This library has been picked up from himiklab's gridview sortable and has been customised to work with ListView. Great work himiklab!
Installation
The preferred way to install this extension is through composer.
- Either run
php composer.phar require --prefer-dist "handysolver/yii2-sortable-list-view-widget" "*"
or add
"handysolver/yii2-sortable-list-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 handysolver\sortablelist\SortableListBehavior; public function behaviors() { return [ 'sort' => [ 'class' => SortableListBehavior::className(), 'sortableAttribute' => 'sortOrder' ], ]; }
- Add action in the controller, for example:
use handysolver\sortablelist\SortableListAction; public function actions() { return [ 'sort' => [ 'class' => SortableListAction::className(), 'modelName' => Model::className(), ], ]; }
Usage
- Use SortableListView as standard ListView with
sortableActionoption. You can also subscribe to the JS event 'sortableSuccess' generated widget after a successful sorting.