YII2 Gridview limiting number rows per page

Using GridView::widget the default number of rows per page is 20. This can be adjusted. This is done when defining the dataProvider.

In the search model, modify dataProvider as follows:

  1. $dataProvider = new ActiveDataProvider([
  2.     'query' => $query,
  3.     'pagination' => [
  4.         'pageSize' => 50,
  5.     ],
  6. ]);

This will set the number of rows per page to 50.

Published by

Joel Bowers

Web developer since 1999. PHP, YII2, Laravel, Javascript, HTML, CSS, jQuery, Perl, Wordpress, MySQL.

2 thoughts on “YII2 Gridview limiting number rows per page”

Leave a Reply

Your email address will not be published. Required fields are marked *