Getting data from dataProvider only viewed on current page


(Sharipov Javlonbek) #1

I need to get data from ArrayDataProvider only viewed on current page (ex. on first page viewed 50 items).

$dataProvider = new ArrayDataProvider([
        'allModels' => Yii::$app->request->get('onlyAvailables', false) ? $data : $allData,
        'pagination' => [
            'pageSize' => 50
        ]
    ]);

How to do it?


(Alexander Makarov) #2
$dataProvider->pagination->page = 2;
$models = $dataProvider->getModels();