In the Controller (/protected/controllers/postController.php)
public function actionAdmin() { $model = new Post('search'); $model->unsetAttributes(); if (isset($_GET['Post'])) $model->attributes = $_GET['Post'];
$this->render('admin', array( 'model' => $model, ));
In the Model (/protected/models/post.php)
public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched.Thank softark for the answer!!
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id); $criteria->compare('foo',$this->foo,true); $criteria->compare('bar',$this->bar,true); ....
return new CActiveDataProvider($this, array( 'criteria' => $criteria, 'sort' => array( 'defaultOrder' => 'post_date DESC', // this is it. ), 'pagination' => array( 'pageSize' => 30, ), )); }
http://www.yiiframework.com/forum/index.php/topic/21523-yii-reverse-cgridview-display-order/
No comments:
Post a Comment