V
V
Vladimir2016-11-22 17:14:24
Yii
Vladimir, 2016-11-22 17:14:24

How to display pagination in LinkPager via dataProvider?

Good day! From the controller I get a variable with the following content:

$query = House::find()->andFilterWhere(['wall' => $modelHouse->wall, 'city' => $modelHouse->city])
                ->andFilterWhere(['between', 'price', $modelHouse->priceFrom, $modelHouse->priceTo])
                ->andFilterWhere(['between', 'area', $modelHouse->areaFrom, $modelHouse->areaTo])
                ->andFilterWhere(['room' => $modelHouse->room,]);

I use it like this:
$dataProvider = new \yii\data\ActiveDataProvider([
    'query' => $query,
    'pagination' => [
        'pageSize' => 3,
    ],
]);

The number of pages to display is specified and they work. But what should be passed to the "pagination" parameter:
<?php \yii\widgets\LinkPager::begin([
        'pagination' => (СЮДА),
    ]) ?>

To display navigation buttons. Thanks in advance for your replies.
PS I'm new to Yii2.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2016-11-22
@slo_nik

Good evening.
For example, pass the parameter pageSize => 5
Will display five records per page
ps More details here

A
Alexey, 2016-11-22
@masterfreelance

I think

<?php \yii\widgets\LinkPager::begin([
        'pagination' => $dataProvider->getPagination(),
    ]) ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question