Yii FindByAttributes in CGridView


$this->widget('zii.widgets.grid.CGridView', array(
 'id'=>'trx-project-grid',
 'dataProvider'=>$model->search(),
 'filter'=>$model,
 'columns'=>array(

 'name',
 array(
 'name'=>'PIC',
 'value'=> function ($data){
 $mstpic = new MstPic();
 $record = $mstpic->findByAttributes(array('idPIC'=>$data->PIC));
 return $record->name;
 },
 'filter'=> CHtml::activeDropDownList($model, 'PIC',
 CHtml::listData(MstPic::model()->findAll(), 'idPIC', 'name'),
 array('empty'=>''))

 ),
 'COD',
 array(
 'name'=>'ProjectENGINE',
 'value' => 'TrxProject::$engine[$data->ProjectENGINE]',
 'filter'=>Chtml::activeDropDownList($model, 'ProjectENGINE',
 TrxProject::$engine,array('empty'=>''))
 ),
 array(
 'class'=>'CButtonColumn',
 'htmlOptions'=>array('width'=>'60')
 ),
 ),
));

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: