yii2-sortable-gridview
yii2-sortable-gridview copied to clipboard
order is not saving in table after sorting
hi, I am using this extension in my project, it doesn't give any error but after sorting the order value is not saving in the table.
please guide me. thanks a lot.
view code
use richardfan\sortable\SortableGridView;
...
<?= SortableGridView::widget([
'dataProvider' => $dataProvider,
// SortableGridView Configurations
'sortUrl' => Url::to(['index']),
// 'sortingPromptText' => 'Loading...',
'failText' => 'Fail to sort',
'columns' => [
'pagename',
'link_title',
'singlelink',
'status',
'linktype',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
controller code
use richardfan\sortable\SortableAction;
public function actions(){
return [
'sortItem' => [
'class' => SortableAction::className(),
'activeRecordClassName' => Menu::className(),
'orderColumn' => 'ord',
],
];
}
public function actionIndex()
{
$searchModel = new MenuSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$singlelink = Menu::find()->where(['<>','singlelink',''])->all();
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'singlelink' => $singlelink
]);
}
Hi @asifrafeeq, it seems to me like you didn't configure sortUrl
correctly, as it points to your index action. It needs to point to your sortItem action.
Make sure to have the network panel opened while testing, so that you can see if the url is properly called, and responds correctly.