Yii2 drop down pagination in GridView


I want to make dorpdown pagination in yii2 gridview. I tried this in my GridView, but don’t clear what should the next step I do to do.



    $form->field($model, 'pagesize')




    ?>&nbsp;&nbsp;records per page


I really need your help guys.

Thank you in advance.

You need to set pagination in your DataProvider:


Pls code example.

What is $model in your code? Is it your SearchModel?

Yes it is search model.

Then you need to modify the search function in your SearchModel to something like this:

    public function search($params)


        $query = YourModel::find();

        $dataProvider = new ActiveDataProvider([

            'query' => $query,

            'pagination' => [

                 'pageSize' => $this->pagesize,




        return $dataProvider;


The "pagesize" in your model should be set when posting, and with the above modification the search will consider it.