1

I want to make Drop down pagination in yii frame work, any sugession will be helpfull. thanks in advance.

4

1 回答 1

3

您可以使用此代码..

在您的控制器中:

 public function actionAdmin(){         
if (isset($_GET['pageSize'])) {
 Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']);
 unset($_GET['pageSize']);}
    $model=new Packages('search');
    $model->unsetAttributes(); 
    if(isset($_GET['Packages']))
        $model->attributes=$_GET['Packages'];       
        $dataProvider=new CActiveDataProvider('Packages'); 
    $this->render('admin',array('model'=>$model,'dataProvider'=>$dataProvider,
    ));
}  

在模型搜索功能中使用这个

return new CActiveDataProvider(get_class($this),array(
            'pagination'=>array(
                'pageSize'=> Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']),
            ),
            'criteria'=>$criteria,
    ));  

在你看来使用这个

$pageSize=Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']); 

echo CHtml::dropDownList('pageSize',$pageSize,array(10=>10,20=>20,50=>50,100=>100,500=>500,1000=>1000),array('onchange'=>"$.fn.yiiGridView.update('packages-grid',{ data:{pageSize: $(this).val() }})",'empty'=>'-- Select Page Range --','style'=>'width:198px;'));

现在在你的 yii 项目中实现了下拉分页。

于 2013-05-15T13:36:37.647 回答