PHP code example of morning-bird / yii2-sortable-gridview
1. Go to this page and download the library: Download morning-bird/yii2-sortable-gridview 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/ */
morning-bird / yii2-sortable-gridview example snippets
use richardfan\sortable\SortableAction;
public function actions(){
return [
'sortItem' => [
'class' => SortableAction::className(),
'activeRecordClassName' => YourActiveRecordClass::className(),
'orderColumn' => 'name_of_field_storing_ordering',
],
// 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
];
}
use richardfan\sortable\SortableGridView;
<?= SortableGridView::widget([
'dataProvider' => $dataProvider,
// SortableGridView Configurations
'sortUrl' => Url::to(['sortItem']),
'sortingPromptText' => 'Loading...',
'failText' => 'Fail to sort',
'columns' => [
// Data Columns
],
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.