YII1 clistview数据为空

YII1 clistview data is empty

我的项目中有自定义下拉分页并使用 CListView 显示项目,但它无法正常工作。无论我 select 在下拉列表中的数字或页码,列表的内容都是空的。我可以看到摘要编号已更改并正确显示,但未显示列表。我缺少什么?

下面是模型 - candidateSearch() 代码:

public function candidateSearch()
{
    $criteria = new CDbCriteria;

    $criteria->compare('can_id',$this->can_id);

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

控制器代码如下:

public function actionIndex()
{
    if (isset($_GET['pageSize'])) 
    {
        Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']);
        unset($_GET['pageSize']);
    }

    $model = new JbMeetGreet('candidateSearch');
    $model->unsetAttributes();  // clear any default values
    $model->can_id = Yii::app()->user->id;
    $model->created_by = Yii::app()->user->id;
    $model->created_by_lvl = Yii::app()->user->user_level;

    //search function
    if(isset($_POST['JbMeetGreet']))
    {
        $model->attributes = $_POST['JbMeetGreet'];
    }

    $this->render('index', array('model'=>$model));
}

下面是索引页代码:

$pageSize = Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']); 
    echo CHtml::dropDownList('pageSize',$pageSize,array(5=>5,10=>10,15=>15,20=>20,25=>25,30=>30),
    array('onchange'=>"$.fn.yiiListView.update('meet-greet-grid',{ data:{pageSize: $(this).val() }})",
    'empty'=>'-- Select Page Range --','style'=>'width:100%;'));

$this->widget('zii.widgets.CListView',array(
    'id'=>'meet-greet-grid',
    'dataProvider'=>$model->candidateSearch(),
    'itemView'=>'_profile_list',
    'template'=>'{summary}{pager}{items}',
    'summaryText'=>'Result {start} - {end} of {count} results',
});

您必须将 dropDownList 添加到您的网格中(以便 ajax 调用工作):

// into your view

$pageSize = Yii::app()->user->getState('pageSize', Yii::app()->params['defaultPageSize']);
$perPagina = CHtml::dropDownList('pageSize', $pageSize, array(5=>5,10=>10,15=>15,20=>20,25=>25,30=>30),
        array('onchange' => "$.fn.yiiGridView.update('meet-greet-grid',{ data:{pageSize: $(this).val() }})")
    );

$this->widget('zii.widgets.CListView',array(
    'id'=>'meet-greet-grid',

    // add this
    'header' => $perPagina,

    'dataProvider'=>$model->candidateSearch(),
    'itemView'=>'_profile_list',
    'template'=>'{summary}{pager}{items}',
    'summaryText'=>'Result {start} - {end} of {count} results',
});

我设法解决了。我的项目视图页面中有动画。删除动画代码,显示后续页面数据。谢谢。