Hello, I need to do a search and pagination. Using gii made a search model. For search I use searchModel -
$searchModel = new ObjectInfoSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
For pagination -
$pages = new Pagination(['totalCount' => $query->count(), 'pageSize' => 2]); $object = $query->offset($pages->offset) ->limit($pages->limit) ->all();
For output in the view I do not use GridView, but use foreach array. And this is the only way: To search, you need to transfer to the dataProvider
<?php foreach ($dataProvider->getModels() as $item) : ?>
And for pagination, the $ object variable
<?php foreach ($object as $item) : ?>
In the first cases, pagination works, but not from the first page - from the moment of switching to another page in the pager, when the url is formed, everything works.
So the question is how to combine these conditions ??
$object
variable? If I understand correctly, you end up with the same thing as in$dataProvider->getModels()
. - Bookin