markot
(Todorovski Marko)
September 28, 2014, 5:06pm
1
Hello,
How can I implemented dynamic page size via a drop down using the GridView widget in Yii2? I want to have a dropdown next to each table that has the options of 10, 20, 50 and 100 results per page like it is done in jQuery datatables. Is there a native option for this?
Thanks
robsch
(Robert Schneider)
September 29, 2014, 12:01pm
2
Did you have a look at the doc?
http://www.yiiframework.com/doc-2.0/yii-data-activedataprovider.html
You would have to pass the drop down value to the data provider configuration.
markot
(Todorovski Marko)
September 29, 2014, 4:06pm
3
Yes, but I was looking for a native functionality - a native dropdown embedded in the GridView widget.
Now I have another question: How can I pass the dropdown parameter together with the filters of the grid?
Suppose I have this code in the view:
<?= Html::dropDownList('pagesize', 10,
array(10 => 10, 20 => 20, 50 => 50, 100 => 100),
array('id' => 'pagesize')
) ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'code',
'name',
'create_time',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
How can I pass the value of the "pagesize" select through _GET together with the filters from the grid (the searches)?
andrew1
(Admin)
September 29, 2014, 6:19pm
4