yii中给CGridView设置默认的排序根据时间倒序的方法
原创
©著作权归作者所有:来自51CTO博客作者dcj3sjt126com的原创作品,请联系作者获取转载授权,否则将追究法律责任
public function searchWithRelated() {
$criteria = new CDbCriteria;
$criteria->together = true; //without this you wont be able to search the second table's data
$criteria->with = array('mySecondTable');
$criteria->compare('id', $this->id, true);
$criteria->compare('mySecondTable.column', $this->mySecondTable_column, true);
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
'sort'=>array(
[color=red] 'defaultOrder'=>'t.create_time DESC',[/color]
),
'pagination' => array(
'pageSize' => 100,
),
));
}