PHP code example of oonne / yii2-sortable-grid-view

1. Go to this page and download the library: Download oonne/yii2-sortable-grid-view library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oonne / yii2-sortable-grid-view example snippets


use oonne\sortablegrid\SortableGridBehavior;

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

use oonne\sortablegrid\SortableGridAction;

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

use oonne\sortablegrid\SortableGridView;

SortableGridView::widget([
    'dataProvider' => $dataProvider,
    'sortableAction' => ['/bannersuper/sort'],
    'columns' => [
        [
            'class' => 'yii\grid\SerialColumn',
            'contentOptions' => ['class' => 'sortable-handle'],
        ],
        [
            'attribute' => 'sName',
        ],
    ]
])