Change number of rows shown in GridView in Yii2

or like that

public function actionIndex() {
 $searchModel = new SettingSearch();
 $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
 $dataProvider->pagination = ['pageSize' => 100];

 return $this->render('index', [
  'searchModel' => $searchModel,
  'dataProvider' => $dataProvider,
  ]);
}

To change the number of items displayed per page, you need to set pagination in your data provider.

Example:

$dataProvider = new ActiveDataProvider([
    ...
    'pagination' => [
        'pageSize' => 10,
    ],
]);

As for removing information about displayed items you need to remove summary from layout:

<?= GridView::widget([
    ...
    'layout' => "{items}\n{pager}",
]) ?>

Official docs:

  • BaseDataProvider $pagination
  • Pagination $pageSize
  • GridView $layout

Tags:

Gridview

Yii2