greshnik/yii2-grid-sort-column

Bootstrap Grid Sort Column Widget for Yii2

Installs: 243

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 1

Type:yii2-extension

1.0.9 2015-12-09 22:23 UTC

This package is not auto-updated.

Last update: 2024-12-25 19:53:18 UTC


README

Installation

The preferred way to install this extension is through composer.

Either run

composer require greshnik/yii2-grid-sort-column "*"

or add

"greshnik/yii2-grid-sort-column" : "*"

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

Usage

Example

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],

        'id',
        'name',
        'class',

        ['class' => 'yii\grid\ActionColumn'],
        ['class' => 'app\gridSortColumn\SortColumn']
    ],
]); ?>

Example add sort action in controller

public function actions()
{
    return [
        'swap' => [
            'class' => 'app\gridSortColumn\Swap',
            'model' => new Mark,
            'attribute' => 'sortAttribute'
        ]
    ];
}

Example add behavior in model

public function behaviors()
{
    return [
        'sort' => [
            'class' => 'app\gridSortColumn\SortBehavior',
            'attribute' => 'sort'
        ]
    ];
}

License

The BSD License (BSD). Please see License File for more information.