Spróbuj coś takiego:
[list=1]
[*]Wygeneruj model dla tabelki łącznikowej (ArticlesCategories) oraz CRUD dla niego. Trzeba będzie jeszcze uzupełnić metodę search tego modelu, dodając grupowanie i zmieniając obsługę pola categoryId:
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('articleId',$this->articleId);
if (is_array($this->categoryId)) {
$criteria->addInCondition('categoryId',$this->categoryId);
} else {
$criteria->compare('categoryId',$this->categoryId);
}
$criteria->group = 'articleId';
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
[*]Do /protected/widgets/grid/ wrzuć klasę:
<?php
Yii::import('zii.widgets.grid.CDataColumn');
class CDataColumnCategories extends CDataColumn {
protected function renderFilterCellContent()
{
if(is_string($this->filter)) {
echo $this->filter;
} else if($this->filter!==false && $this->grid->filter!==null && $this->name!==null && strpos($this->name,'.')===false) {
if (isset($_GET['ArticlesCategories']['categoryId'])) {
$selectedValues = $_GET['ArticlesCategories']['categoryId'];
} else {
$selectedValues = null;
}
if (is_array($this->filter)) {
echo CHtml::checkBoxList($this->name, $selectedValues, $this->filter, array('id'=>false));
} else if($this->filter===null) {
echo CHtml::activeTextField($this->grid->filter, $this->name, array('id'=>false));
}
} else {
parent::renderFilterCellContent();
}
}
}
[*]CGridView w /protected/views/articlesCategories/admin.php powinien wyglądać podobnie:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'articles-categories-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'articleId',
array(
'class' => 'application.widgets.grid.CDataColumnCategories',
'name' => 'ArticlesCategories[categoryId]',
'value' => '$data->category->name',
'filter' => CHtml::listData(Categories::model()->findAll(), 'id', 'name'),
),
array(
'name' => 'articleId',
'value' => '$data->article->title'
),
array(
'header' => 'Treść',
'value' => 'mb_substr($data->article->text, 1, 100)'
),
array(
'class'=>'CButtonColumn',
),
),
)); ?>
[/list]
Pewnie da się z tego wykombinować bardziej uniwersalne rozwiązanie. 
3014
