nterms / yii2-pagesize-widget

Widget for enabling dynamic page size selection on yii2 GridView
MIT License
38 stars 18 forks source link

yii2-pagesize-widget

PageSize widget is an extension to the Yii2 GridView that enables changing the size of a page on GridView.

Latest Stable Version Total Downloads Latest Unstable Version License

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist nterms/yii2-pagesize-widget "*"

or add

"nterms/yii2-pagesize-widget": "*"

to the require section of your composer.json file.

Usage

To use this widget with a GridView, add this widget to the view where the GridView is:

<?php echo \nterms\pagesize\PageSize::widget(); ?>

and set the filterSelector property of GridView as shown in following example.

<?= GridView::widget([
     'dataProvider' => $dataProvider,
     'filterModel' => $searchModel,
        'filterSelector' => 'select[name="per-page"]',
     'columns' => [
         ...
     ],
 ]); ?>

Please note that per-page here is the string you use for pageSizeParam setting of the PageSize widget.

Configurations

Following properties are available for customizing the widget.

License

MIT