When use CGridView to display Active Records with relationship, we should notice some points

  1. For CGridView’s Columns properties, you should use ‘relation[property]’ as your columns name (e.g. user[nick]). Or this column name will be fillet by CDataColumn::renderFilterCellContent() defined in Yii/zii/widgets/grid/CDataColumn.phps . (refer code strpos($this->name,'.')==false conditions normally in line 94).

  2. use $data->relation->property as CGridView’s Column’s value property. such as value=>'$data->user->nick'

  3. Create your search condition into Model’s search method by visit $_GET variable.

  4. Add $_GET to attributes in you Controller’s list method, so the filter header could remember the last typed value.

  5. Of course , just add with=>array('relation') and together=true property into your the CDbCriteria instance used in Model’s search method