Searching in the forum i found a easy way to select paging size of Cgridview
But actually need do it with a CArrayDataProvider not with CRUD auto generated code, trying this obtain the next error:
Trying to get property of non-object.
In the post explain a similar error, but that isn’t my case because i’m not calling any item from the dataprovider to build the button Element.
Here is my code
In the view
CVarDumper::dump(Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']),10,true);exit;
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'extension-grid',
'dataProvider'=>$dataProvider,
'columns'=>array(
array('name'=>'Name', 'header'=>'Name'),
array('class'=>'CButtonColumn',
'header'=>CHtml::dropDownList("pageSize",
//$pageSize,
"",
array(20=>20,50=>50,100=>100),
array(
//
// change "user-grid" to the actual id of your grid!!
"onchange"=>
"$.fn.yiiGridView.update('user-grid',{ data:{pageSize: $(this).val() }})",
)
),
),
),
));
I think the error be in the view, because in the first load the page is ok, but when the page tries to load again i get the error.
Even if i keep this code, the same error is raised
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'extension-grid',
'dataProvider'=>$dataProvider,
'columns'=>array(
array('name'=>'Name', 'header'=>'Name'),
array('class'=>'CButtonColumn',
),
),
));
I will appreciate your help…