- Published on
Yii2 How to setup pagination style and other labels
- Authors
- Name
- Bal Singh
In Yii2 some time we need to setup pagination style according to our need or according to our theme. So setup style of pagination in Yii2 is very easy. Its same as in Yii.
<?= ListView::widget([
'dataProvider' => $dataProvider,
'itemView' => '_view',
'pager' => [
'options'=>['class'=>'pagination'], // set clas name used in ui list of pagination
'prevPageLabel' => 'Previous', // Set the label for the "previous" page button
'nextPageLabel' => 'Next', // Set the label for the "next" page button
'firstPageLabel'=>'First', // Set the label for the "first" page button
'lastPageLabel'=>'Last', // Set the label for the "last" page button
'nextPageCssClass'=>'next', // Set CSS class for the "next" page button
'prevPageCssClass'=>'prev', // Set CSS class for the "previous" page button
'firstPageCssClass'=>'first', // Set CSS class for the "first" page button
'lastPageCssClass'=>'last', // Set CSS class for the "last" page button
'maxButtonCount'=>10, // Set maximum number of page buttons that can be displayed
],
]); ?>
Thats it. You can use pager parameter in ListView and in GridView as well. Now you can write css of paginationClassName according to your requirement.