yii2-sortable-gridview icon indicating copy to clipboard operation
yii2-sortable-gridview copied to clipboard

order is not saving in table after sorting

Open asifrafeeq opened this issue 7 years ago • 1 comments

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
        ]);
    }

10-dec-17 12-17-46 pm

asifrafeeq avatar Dec 10 '17 08:12 asifrafeeq

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.

machour avatar Dec 20 '17 10:12 machour