paginationyii2page-size

Is it possiable to change gridview pagination button count globally in yii2?


this is working perfect. but, I want to globalize this pager setting

GridView::widget([
    'dataProvider' => $dataProvider,
    'pager' => [
        'maxButtonCount' => 5,
        'options' => [
            'tag' => 'ul',
            'class' => 'pagination pagination-sm',
        ]
    ],
    'columns' => .....   
]);

my code is this in component section. But, It is not working.

'components' => [
    .....

    'pager' => [
        'class' => yii\widgets\LinkPager::class,
        'maxButtonCount' => 5,
        'options' => [
            'tag' => 'ul',
            'class' => 'pagination pagination-sm',
        ]
    ],
],   

Solution

  • I found a solution to handle pagination button count globally

    $config = [
        ....
        'container' => [
            'definitions' => [
                'yii\widgets\LinkPager' => [
                    'maxButtonCount' => 6,
                    'options' => [
                        'tag' => 'ul',
                        'class' => 'pagination', //pagination-sm
                    ]
                ],
            ],
        ],
        'components' => [
            ...
        ],
    ];