Reputation: 2724
I'm trying to change the amount of rows shown on the gridView (Yii2) but I couldn't find anything in their documentation.
Is it even possible or do I have to have to use another extension? (Kartik for example.)
Also, is it possible to remove "Showing x of x items" as shown beneath?
Upvotes: 17
Views: 16157
Reputation: 99
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,
]);
}
Upvotes: 8
Reputation: 33538
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:
Upvotes: 18