A
A
Alexander N++2016-01-18 14:18:00
Yii
Alexander N++, 2016-01-18 14:18:00

Yii2 dataProvider pagination not setting limit?

Made for myself a custom GridView widget with gadgets.
This is how the limit is set in the controller in the debug logs, it is visible that the request passed with a limit of 300

$query = Stat::find();
  $dataProvider = new \yii\data\ActiveDataProvider([
      'query' =>$query ,
  ]);
$dataProvider->pagination->pageSize = 300;

I need to set a limit from the widget
public function __construct($config = []){

        if(isset($config['dataProvider'])){
            $config['dataProvider']->pagination->pageSize = 500;
        }
        parent::__construct($config);
    }

in the logs there is also a limit of 300 and should be 500
if you make a comment on the limit of 300, then in the logs the limit is 20 and should be 500
Magic.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita, 2016-01-18
@bitver

Try to do this not in the constructor, but in the init() method by accessing the dataProvider field. It works for me.

L
LAV45, 2016-01-18
@LAV45

You need to fix the pageSizeLimit to pass the check

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question