isavon/yii2-sortablegrid

The extension for Yii2 Framework

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

1.0 2022-07-08 10:42 UTC

This package is auto-updated.

Last update: 2025-06-11 11:24:13 UTC


README

yii2-sortablegrid

Installation

The preferred way to install this extension is through composer.

To install, either run

$ php composer.phar require isavon/yii2-sortablegrid "@dev"

or add

"isavon/yii2-sortablegrid": "@dev"

to the require section of your composer.json file.

Changes

NOTE: Refer the CHANGE LOG for details on changes to various releases.

Usage

Add SortableGridAction to your controller.

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

Add SortableGridBehavior to your model.

public function behaviors()
{
    return [
        [
            'class' => SortableGridBehavior::className(),
            'sortableAttribute' => 'sortOrder',
        ],
    ];
}

And add SortableGridView to your view file.

<?= SortableGridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
        'id',
        'name',
        'created_at',
        [
            'class' => 'yii\grid\ActionColumn',
            'template' => '{update} {delete}',
        ],
    ],
]) ?>

Done!