PHP code example of isavon / yii2-sortablegrid

1. Go to this page and download the library: Download isavon/yii2-sortablegrid 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/ */

    

isavon / yii2-sortablegrid example snippets


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

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

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