可以用以下三種方法
1.在view裡面 復制代碼 代碼如下:
<span style="color:#000000;">$provider=$model->search();
$provider->pagination->pageSize=20;
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'link-grid',
'dataProvider'=>$provider,</span>
2.在model的search方法裡 復制代碼 代碼如下:
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
'pagination'=>array(
'pageSize'=> 5,
),
));
3.在controller裡 復制代碼 代碼如下:
$dataProvider=new CActiveDataProvider('Post', array(
'pagination'=>array(
'pageSize'=>Yii::app()->params['postsPerPage'],
),
'criteria'=>$criteria,
));