I am able to sort my data fine. Even the filter shows up sorted. The problem is that the filter does not filter the data! I am calling another active record into the current record. When I select an item from the filter dropdown, nothing happens. Please help!
MODEL:
public $gGeneSymbol_search;
public function rules(){
return array(
array('gGeneSymbol_search', 'safe', 'on'=>'search'));}
public function relations(){
return array(
'geneName'=>array(self::BELONGS_TO, 'Gene', 'gene_id'))
}
public function attributeLabels(){
return array(
'gGeneSymbol_search' => 'Gene');}
public function search(){
$criteria->compare('geneName.gGeneSymbol', $this->gGeneSymbol_search, true);
return new CActiveDataProvider($this, array(
'criteria'=>array(
'with'=>array('geneName')),
'sort'=>array(
'attributes'=>array(
'gGeneSymbol_search'=>array(
'asc'=>'geneName.gGeneSymbol',
'desc'=>'geneName.gGeneSymbol DESC'),
you first declare $criteria variable and apply your filter, and then you are not passing it to CActiveDataProvider but create new one (in “array()” notation) with only ‘with’ attribute. You should add $criteria->with to the main variable and pass whole criteria obcject to data provider…