yii2-sortable-grid-view-widget Sortable modification of standard Yii2 GridView widget.

  1. Installation
  2. Usage
  3. Resources

Sortable GridView Widget for Yii2. With the ability to sort the rows relative to each other, the result is stored as a database.

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 int attribute, 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 sortableAction option. You can also subscribe to the JS event 'sortableSuccess' generated widget after a successful sorting.

Resources

0 0
2 followers
0 downloads
Yii Version: 2.0
License: MIT
Category: User Interface
Developed by: himiklab
Created on: Sep 23, 2014
Last updated: 10 years ago

Related Extensions