Aadhira
(Kalaimaruthalingam)
1
hi all,is there any way to sort the content displayed in grid view?if so kindly help me.
Thanks in advance 
<?php
$duplicateData = Yii::app()->db->createCommand()
->select('*')
->from('mail')
->queryAll();
$dataProvider = new CArrayDataProvider($duplicateData, array(
'pagination' => array(
'pageSize' => 10,
),
));
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $dataProvider->search(),
array(
'name' => 'E_Id',
'header' => 'Email Id'
),
array(
'name' => 'Receiver',
'header' => 'Receiver'
),
)
));
?>
gv0zd
(Gv00000zd)
2
In my code I use this
public function search()
{
$criteria=new CDbCriteria;
$criteria->compare('t.id',$this->id);
$criteria->compare('typeId',$this->typeId);
$criteria->compare('countryId',$this->countryId);
$criteria->compare('t.title',$this->title,true);
$criteria->compare('content',$this->content,true);
$criteria->compare('created',$this->created,true);
$criteria->compare('deleted',$this->deleted,true);
$criteria->with=array('type', 'country');
return new CActiveDataProvider(
$this,
array(
'criteria'=>$criteria,
'sort'=>array(
'defaultOrder'=>'type.id ASC, country.title ASC, t.title ASC',
'attributes'=>array(
'type.title'=>array(
'asc'=>$expr='type.title',
'desc'=>$expr.' DESC',
),
'country.title'=>array(
'asc'=>$expr='country.title',
'desc'=>$expr.' DESC',
),
'*'
)
),
'pagination'=>array(
'pageSize'=>Yii::app()->params['pagination']['backoffice'],
),
)
);
}
Aadhira
(Kalaimaruthalingam)
3
i dono for what $criteria->with=array(‘type’, ‘country’); is used .kindly explain it
fouss
(Jsfousseni)
4
the relational query criteria. This is used for fetching related objects in eager loading fashion
http://www.yiiframework.com/doc/api/1.1/CDbCriteria#with-detail
Aadhira
(Kalaimaruthalingam)
5
had seen it already ,but no clear idea about it
le_top
(Ext Yiiframework Com)
6
Hi
Have a look at my extension RelatedSearchBehavior which makes sorting on related tables really easy to do.