Hi,
I want to make dorpdown pagination in yii2 gridview. I tried this in my GridView, but don’t clear what should the next step I do to do.
<label>
<?=
$form->field($model, 'pagesize')
->dropDownList(
["1"=>"1","10"=>"10","25"=>"25","50"=>"50","100"=>"100"],
)->label('');
?> records per page
</label>
I really need your help guys.
Thank you in advance.
patrickm
(Yiiframework)
2
patrickm
(Yiiframework)
4
What is $model in your code? Is it your SearchModel?
patrickm
(Yiiframework)
6
Then you need to modify the search function in your SearchModel to something like this:
public function search($params)
{
$query = YourModel::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => $this->pagesize,
],
]);
[...]
return $dataProvider;
}
The "pagesize" in your model should be set when posting, and with the above modification the search will consider it.