yiicod/yii2-pagesizepager

Perpager extension for Yii 2 framework

Installs: 852

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

1.0.1 2018-02-18 21:11 UTC

This package is auto-updated.

Last update: 2024-11-27 01:52:37 UTC


README

Provides functionality to add page size pager for any grid and save chosen value in file storage. This is liyunfang\yii2-widget-linkpager fork.

Latest Stable Version Total Downloads Scrutinizer Code QualityCode Climate

Usage

You can choose exists provider:

'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