A
A
Alex Mirgorodskiy2018-03-17 21:02:45
Yii
Alex Mirgorodskiy, 2018-03-17 21:02:45

How to correctly specify routes in the pager?

Hello everyone, I ran into a problem, there is a regular page with pagination

$query = FalseBase::find()->where(['status' => 1])->orderBy(['id' => SORT_DESC]);

        
        $pages = new Pagination([
            'totalCount' => $query->count(), 'pageSize' => 6,
            'forcePageParam' => false, 'pageSizeParam' => false,
            'route' => 'admin/false-filter/index'
        ]);

        
        $falsers = $query->offset($pages->offset)->limit($pages->limit)->all();

        return $this->render('index',compact('falsers','pages'));

And on it there is an AJAX-om removal, when I delete, I return an updated list of data, but from another controller
public function actionDelete($id)
    {

        $model = $this->findModel($id);

        //Если модель удаленна
        if ($model->delete()) {

            //Удалим ее картинки
            $deleter = new ImageDeleter;
            $deleter->deleteImg($id, 'False');
        }

        //Запрос обновленного списка кидал
        $query = FalseBase::find()->with('phones')->with('addresses')->with('photo')->where(['status' => [1,2]])->orderBy(['id' => SORT_DESC]);

        //Пейджер
        $pages = new Pagination([
            'totalCount' => $query->count(), 'pageSize' => 6,
            'forcePageParam' => false, 'pageSizeParam' => false,
            'route' => 'admin/false/index'
        ]);

        $falsers = $query->offset($pages->offset)->limit($pages->limit)->all();


        return $this->renderAjax('index', compact('falsers','pages'));

    }

And if I don’t specify the line 'route' => 'admin/false/index' , the urle remains the wrong thing (Pjax-pagination), and if I specify, then pagination does not work (please help me, I already understand that I didn’t implement it correctly, but how to fix it now?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question