yii2
yii2 copied to clipboard
pageSize & totalCount returning wrong values
What steps will reproduce the problem?
Similar to https://github.com/yiisoft/yii2/issues/17093.
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => 1,
'totalCount' => 1,
],
]);
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => 1,
],
'totalCount' => 1,
]);
The pageSize doesn't work, neither totalCount.
What is the expected result?
Page Size having the size set in the Model Search $dataProvider attribute pageSize, and the totalCount models as the Model Search $dataProvider attribute totalCount
What do you get instead?
The Widget (ListView and/or GridView) loads all the models found and the page size is according with the total of models found.
No matter if I set totalCount to 1 or more, if the query gets more than the totalCount, the totalCount will be it instead of configured value, and if in the pageSize I set 1, the number of pages will be by default 20.
Additional info
| Q | A |
|---|---|
| Yii version | 2.0.45 |
| PHP version | 7.4 |
| Operating system | openSUSE TW/CloudLinux |
If in the controller, I set $dataProvider->pagination->pageSize = 1; the pageSize will respet this value.
If in the controller, I set $dataProvider->totalCount = 1; the totalCount will respet this value.
If in the same controller I set $dataProvider->pagination->totalCount = 1; it neither will work
For paginator to work u need to give ur dataprovider an id. That could solve the issue with pagesize, not sure.