GridView items per page

I’ve seen that a ActiveDataProvider has a setPagination method that allows to change pageSize attibute so GridView will show just as elements as you want.

Is there a way to change this page size attribute when using a GridView::widget call? I think is a better to change it in view side and not in model…

You set pagination config in controller, not in model.

Infact you write in controller’s action:




$dataProvider = new CActiveDataProvider( $model, array(

'pagination' => array('pageSize' => 25)

);



to paginate 25 items per page.

Perhaps I’m doing something wrong (I’m totally newbie in yii2). In my action I instantiate a ModelSearch and I invoke search method. This method (inside model) returns a data provider. Of course I can modify this data provider at controller level and call setPagination mehod, but I think is a better solution to do this at view level. Is there any way to achieve this using GridView options?

View’s time in general shouldn’t manipulate data, but only display these.

I think it’s better at controller time.

Ok. I’ll do this way then. Thank you!