Reputation: 129
I have working with Yii2.0, in my requirement i want to show all the records in my particular grid(with out pagination), i mean if suppose i having 250 records(row) means all the records will be list in that grid , then i want the custom combo-box to limit the records like(10,50,100) this.
i want the combo-box
do you have any idea and suggestion to implement as per the above requirement Thanks in advance for your support and idea
Upvotes: 2
Views: 6406
Reputation: 440
You can set pagination as false so that you can display all records at once:
$dataProvider = new ActiveDataProvider([
'query' => Yii::@app->find()->all(),
'pagination' => false,
]);
Then if you want to implement a combo-box to limit records, create a form that asks the limit then send the form to itself(or to which page that handles the query of records) and make the database query dynamic. Like:
$limit = (isset(Yii::$app->request->post('limit'))?Yii::$app->request->post('limit'):'0');
$dataProvider = new ActiveDataProvider([
'query' => Yii::@app->find()->where('user_id = :user_id')->limit($limit)->all(),
'pagination' => false,
]);
I hope this helps!
Upvotes: 9