title: set pagination for gridview have filters in yii2 basic app
body: <p>i use yii2 basic app and have gridview with filter and search.
   i want pagination that for each 10 record. what can i do?</p>
  
  <p>i know add pagination in dataprovider but how can add this to my function?</p>
  
  <p>please help me.
  this is important for me.
   i do many search but can't find solution for this</p>
  
  <p>controller:</p>
  
  <pre><code>public function actionIndex()
  {
      $searchModel = new ContactSearch();
      $dataProvider = $searchModel-&gt;search(Yii::$app-&gt;request-&gt;queryParams);
  
      return $this-&gt;render('index', [
          'searchModel'=&gt;$searchModel,
          'dataProvider' =&gt; $dataProvider,
      ]);
  }
  </code></pre>
  
  <p>model\contactsearch.php</p>
  
  <pre><code> &lt;?php
   namespace app\models;
  
   use app\models\Contact;
   use yii\base\Model;
   use yii\data\ActiveDataProvider;
  
  class ContactSearch extends Contact {
  public function rules() {
      return [
  
          [['f_name', 'l_name', 'phone_number', 'Mobile_number'], 'safe'],
      ];
  }
  
  public function scenarios() {
      return Model::scenarios();
  }
  
  public function search($params) {
      $query = Contact::find();
  
      $dataProvider = new ActiveDataProvider([
          'query' =&gt; $query,
          'sort' =&gt; [
      'defaultOrder' =&gt; [
          'l_name' =&gt; SORT_DESC,
      ],
  
  ],
      ]);
  
      if (!(($this-&gt;load($params) &amp;&amp; $this-&gt;validate()))) {
          return $dataProvider;
      }
  
      $query-&gt;andFilterWhere(['like', 'f_name', $this-&gt;f_name])
            -&gt;andFilterWhere(['like', 'l_name', $this-&gt;l_name])
            -&gt;andFilterWhere(['like', 'phone_number', $this-&gt;phone_number])
            -&gt;andFilterWhere(['like', 'Mobile_number', $this-&gt;Mobile_number]);
  
            //-&gt;andorderBy('id asc');
  
      return $dataProvider;
  
  }
  }
  
  ?&gt;
  </code></pre>
  
  <p>view</p>
  
  <pre><code>  &lt;?= GridView::widget([
      'dataProvider' =&gt; $dataProvider,
      'filterModel'=&gt;$searchModel,
      'columns' =&gt; [
          ['class' =&gt; 'yii\grid\SerialColumn'],
  
          'f_name',
          'l_name',
          'phone_number',
          'Mobile_number',
  
          ['class' =&gt; 'yii\grid\ActionColumn'],
      ],
  ]); ?&gt;
  </code></pre>