On creation of a new model, say on creation of new Post I want the page to redirect to the admin view with the new record that was created selected. So there are 2 issues here:
This new record may not be on the first page of the CGridView.So how do I pragmatically navigate to the page?
How can I set the selection for the row displaying the new record
You can set ordering in CGridView to ensure newest record is on the top like this:
in your model class:
public function search(){
$criteria=new CDbCriteria;
... your code...
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
'sort'=>array(
'defaultOrder'=>'id DESC',
)
));
}