<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
carmineplaitano / yii2-sortable-gridview-plus example snippets
use richardfan\sortable\SortableAction;
public function actions(){
return [
'sortItem' => [
'class' => SortableAction::className(),
'activeRecordClassName' => YourActiveRecordClass::className(),
'orderColumn' => 'name_of_field_storing_ordering',
'startPosition' => 1, // optional, default is 0
],
// your other actions
];
}
use richardfan\sortable\SortableGridView;
<?= SortableGridView::widget([
'dataProvider' => $dataProvider,
// you can choose how the URL look like,
// but it must match the one you put in the array of controller's action()
'sortUrl' => Url::to(['sortItem']),
'columns' => [
// Data Columns
],
]);
$dataProvider->pagination = false;
use richardfan\sortable\SortableAction;
public function actions(){
return [
'sortItem' => [
'class' => SortableAction::className(),
'activeRecordClassName' => Articles::className(),
'orderColumn' => 'sortOrder',
],
// your other actions
];
}