Provides functionality to add page size pager for any grid and save chosen value in file storage. This is liyunfang\yii2-widget-linkpager fork.
You can choose exists provider:
- FileProvider
- MongoProvider (You should have https://github.com/yiisoft/yii2-mongodb)
- Or you can write your self provider and configute di container
'container' => [
'singletons' => [
\yiicod\pagesizepager\providers\ProviderInterface::class => [
'class' => \yiicod\pagesizepager\providers\MongoProvider::class
]
],
],
Add for any grid
echo \yii\grid\GridView::widget([
'id' => 'uniqueGridId',
'dataProvider' => $dataProvider,
'filterSelector' => yiicod\perpager\widgets\PageSizePager::getFilterSelector($dataProvider),
'pager' => [
'class' => yiicod\perpager\widgets\PageSizePager::class,
'gridIdentifier' => 'uniqueGridId',
]
]);
Then add in data provider pagination section (for chosen grid)
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => \Yii::$container->get(\yiicod\pagesizepager\providers\ProviderInterface::class)->getPageSize('uniqueGridId'),
],
]);
Note: 'uniqueGridId' must be the same in all places to correct save grid page size