Closed Zdunek closed 2 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I have the same issue as @Zdunek mentioned. When calling $dataProvider->getModels() and dataProvider->setModels($new_models)
the pagination is not working.
Even if I set defaultPageSize pagination is still not visible.
I found the solution.
The problem is that in applyPageSize()
function in line 1122 of DynaGrid.php $dataProvider->pagination gets overridden.
protected function applyPageSize()
{
if (isset($this->_pageSize) && $this->_pageSize !== '' && $this->allowPageSetting) {
/** @var \yii\data\BaseDataProvider $dataProvider */
$dataProvider = $this->gridOptions['dataProvider'];
if ($dataProvider instanceof ArrayDataProvider) {
$dataProvider->refresh();
}
if ($this->_pageSize > 0) {
$dataProvider->setPagination(['pageSize' => $this->_pageSize]); // <======= the line where pagination get's overriden
} else {
$dataProvider->setPagination(false);
}
if ($dataProvider instanceof SqlDataProvider) {
$dataProvider->prepare(true);
}
$this->gridOptions['dataProvider'] = $dataProvider;
}
}
Currently I fixed it with $dataProvider->setPagination(['pageSize' => $this->_pageSize, 'totalCount' => $dataProvider->getTotalCount()]);
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I try make treegrid and i use $dataProvider->getModels() and dataProvider->setModels($new_models), but, after use $dataProvider->getModels(); pagination in dynagrid stop working. Stop showing pagination, stop working param pageSize and probably other For problem confirmation i tried kartik\grid\GridView and in this view everything working property.
Dynagrid v1.5.1
Edit: Problem is when is not set defaultPageSize in module config. When is set something not 0 problem is solved.