Skip to content

naduvko/yii2-sortable-grid-view-widget

 
 

Repository files navigation

Sortable GridView Widget for Yii2

Sortable modification of Kartik GridView widget.

Total Downloads Latest Stable Version License

Installation

The preferred way to install this extension is through composer.

  • Either run
php composer.phar require --prefer-dist "naduvko/yii2-sortable-grid-view-widget" "*"

or add

"naduvko/yii2-sortable-grid-view-widget" : "*"

to the require section of your application's composer.json file.

  • Add to your database new unsigned int attribute, such sortOrder.

  • Add new behavior in the AR model, for example:

use naduvko\sortablegrid\SortableGridBehavior;

public function behaviors()
{
    return [
        'sort' => [
            'class' => SortableGridBehavior::className(),
            'sortableAttribute' => 'sortOrder'
        ],
    ];
}
  • Add action in the controller, for example:
use naduvko\sortablegrid\SortableGridAction;

public function actions()
{
    return [
        'sort' => [
            'class' => SortableGridAction::className(),
            'modelName' => Model::className(),
        ],
    ];
}

Usage

  • Use SortableGridView as standard GridView with sortableAction option. You can also subscribe to the JS event 'sortableSuccess' generated widget after a successful sorting.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 79.2%
  • JavaScript 20.8%