Hi All,
I have a problem with yii dataprovider.
I want to have data to be shown limited only 30 rows from all data.
Then I want to use the paging of yii gridview, set to 5 per page.
so this is my code :
use yii\grid\GridView;
use app\models\Post;
use yii\data\ActiveDataProvider;
$model = Post::find()->limit(40);
$dataProvider = new ActiveDataProvider(
[
'query'=>$model,
'pagination' => [
'pageSize' => 5,
]
]
);
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'post_id',
'message',
],
]);
It displayed the data, but showing all the data which is 1522 records.
I want to limit the data on the provider by the query (active record) then limit it again by data provider pagination.
40 data to be shown, then 5 per page from 1522 records data.
Any advice ?
Thanks