我創建了下拉篩選器,它是顯示器,但不能正常工作。正如我在search()方法anderstand麻煩Yii CGridView和下拉篩選器
觀點:
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$model->search(),
'filter' => $model,
'columns'=>array(
array(
'name' => 'client_id',
'filter' => CHtml::listData(Client::model()->findAll(), 'client_id', 'name'),
'value'=>'$data->client->name'
),
'task'
)
));
我有表,他們關係如圖下來 型號:
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(
'client' => array(self::BELONGS_TO, 'Client', 'client_id'),
);
}
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->with = array('client');
$criteria->compare('task_id',$this->task_id);
$criteria->compare('client_id',$this->client_id);
$criteria->compare('name',$this->client->name);
$criteria->compare('task',$this->task,true);
$criteria->compare('start_date',$this->start_date,true);
$criteria->compare('end_date',$this->end_date,true);
$criteria->compare('complete',$this->complete);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
它不工作?什麼是輸出? – Stu
我認爲這個wiki可能有一些幫助: [CGridView:Render customized/complex datacolumns](http://www.yiiframework.com/wiki/278/cgridview-render-customized-complex-datacolumns/) – Stu
它的輸出與之前的filterin一樣,我認爲$ this-> client_id在CDbCriteria –