antic-droid / yii2-sortable-grid-view-widget
Modified clone Yii2 sortable GridView widget. https://github.com/himiklab/yii2-sortable-grid-view-widget
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
Installs: 44
Dependents: 2
Suggesters: 0
Security: 0
Type:yii2-extension
pkg:composer/antic-droid/yii2-sortable-grid-view-widget
Requires
This package is not auto-updated.
Last update: 2023-11-09 06:45:57 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, such- sortOrder.
- 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.