I have the same problem with you.
But i found something. If I sort one of the columns and the I click the page links, the pagination works fine.
Here is my code, if you’re interested.
IN MODELS:
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'fparent_id0' => array(self::BELONGS_TO, 'Menu', 'fparent_id'),
'fstatus0' => array(self::BELONGS_TO, 'Status', 'fstatus'),
);
}
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->with = array('fparent_id0','fstatus0');
$criteria->addCondition('t.fparent_id <> 0');
$criteria->compare('t.fid',$this->fid);
$criteria->compare('fparent_id0.fname',$this->fparent_id,true);
$criteria->compare('t.fname',$this->fname,true);
$criteria->compare('t.flink',$this->flink,true);
$criteria->compare('fstatus0.fname',$this->fstatus);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'sort'=>array(
'attributes'=>array(
'fparent_id'=>array(
'asc'=>'fparent_id0.fname',
'desc'=>'fparent_id0.fname DESC',
),
'fstatus'=>array(
'asc'=>'fstatus0.fname',
'desc'=>'fstatus0.fname DESC',
),
'*'
),
),
));
}
IN CONTROLLER:
public function actionAdmin()
{
$model=new Submenu('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Submenu']))
$model->attributes=$_GET['Submenu'];
$this->render('admin',array(
'model'=>$model,
));
}
IN VIEW:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'submenu-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'fid',
array( 'name'=>'fparent_id', 'value'=>'$data->fparent_id0->fname'),
'fname',
'flink',
array( 'name'=>'fstatus', 'value'=>'$data->fstatus0->fname'),
array(
'class'=>'CButtonColumn',
'afterDelete'=>'function(link,success,data){ if(success) $("#statusMsg").html(data); }',
),
),
)); ?>