╃巡洋艦㊣ 2011-06-23 16:41:16 8213次浏览 10条回复 3 1 0

默认生成的代码CGridView的dataProvider是$model->search(); 我们找到模型类的search方法:

public function search()
{
    // Warning: Please modify the following code to remove attributes that
    // should not be searched.
    $criteria=new CDbCriteria;
    $criteria->compare('title',$this->title,true);
    return new CActiveDataProvider(get_class($this), array(
        'pagination'=>array(
        'pageSize'=>20,//设置每页显示20条
    ),
    'sort'=>array(
        'defaultOrder'=>'create_time DESC', //设置默认排序是create_time倒序
    ),
    'criteria'=>$criteria,
    ));
}
觉得很赞
您需要登录后才可以回复。登录 | 立即注册