PHP code example of ivankff / yii2-sortable

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

    

ivankff / yii2-sortable example snippets


public function behaviors()
{
	return [
		...
		'sort' => [
			'class' => 'ivankff\yii2Sortable\SortableBehavior',
			'groupAttributes' => ['parent_id'],
		],
		...
	];
}

public function actions()
{
	return [
		...
		'position' => [
			'class' => 'ivankff\yii2Sortable\BulkPositionAction',
			'model' => [$this, 'findModel'],
		],
		...
	];
}

GridView::widget([
	'columns' => [
		...
		[
			'class' => 'ivankff\yii2Sortable\PositionColumn',
			'attribute'=>'position',
		],
		...
	],
	'panel' => [
		...
		'after' => '<div class="clearfix">' . Html::a('<i class="fas fa-sort-numeric-down"></i> Пересортировать', \yii\helpers\Url::to(['position']), ['data-pjax' => '1', 'data-pjax-container' => 'crud-datatable-pjax', 'class' => 'btn btn-primary float-right kv-position-set']) . '</div>',
		...
	],
]);