Yii Cgridview如何在视图中呈现同一表格中1列中的2个或多个值

Yii Cgridview如何在视图中呈现同一表格中1列中的2个或多个值,yii,cgridview,Yii,Cgridview,我有一个Cgridview,它有多个列。我想合并并呈现1列中3列的值 <?php $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'policy-grid', 'dataProvider'=>$dataProvider, 'filter'=>$dataProvider->model, 'selectableRows' => 1, // you can select only 1 r

我有一个Cgridview,它有多个列。我想合并并呈现1列中3列的值

 <?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'policy-grid',
'dataProvider'=>$dataProvider,
'filter'=>$dataProvider->model,

'selectableRows'   => 1, // you can select only 1 row!!
'selectionChanged'=>'function(id){ var objectId = $.fn.yiiGridView.getSelection(id); 
 if (isNaN(objectId) || objectId == ""){return;} location.href = 
"'.$this->createUrl('policy/view').'&id="+$.fn.yiiGridView.getSelection(id);}',
'htmlOptions'=>array('class'=>'grid-view grid_pointer',),

 'columns'=>array(

  array(
       'name'        => 'compliance',
     'type'        => 'html',
     'value'       => '$data->status == "ACTIVE" ? (CHtml::image($data->compliance == 
    "SUFFICIENT" ? "images/policy_sufficient.png" : "images/policy_insufficient.png")) 
    : "N/A" ',
     'filter'      => VFFormUtil::getFilter(VFFormUtil::POLICY_COMPLIANCE),
     'htmlOptions' => array('style'=>'text-align: center'),
  ),

  array(
       'name'        => 'status',
     'filter'      => VFFormUtil::getFilter(VFFormUtil::ACTIVE_INACTIVE),
     'htmlOptions' => array('style'=>'text-align: center'),
  ),

  array(          

      'name'        => 'coverage_left',
      'htmlOptions' => array('style'=>'text-align: center'),
  ),

  array(
      'name' => 'model_year', 
      'htmlOptions' => array('style'=>'text-align: center'), 
  ),
  'make',
  'model',

正确的方法是在模型中创建一个新的属性变量,并将值
afterFind()
连接起来


请参见,但您必须交换查找和保存函数,因为该用户希望执行相反的操作(将单列拆分为三个字段)。

正确的方法是在模型中创建一个新的属性变量,并将值连接到
afterFind()


请参见,但您必须交换查找和保存函数,因为该用户希望执行相反的操作(将单列拆分为三个字段)。

您可以在模型中创建一个getter:

public function getModelLabel()
{
    return $this->model_year.' '.$this->make.' '.$this->model;
}

然后,您可以在GridView中使用
modelLabel
,就像它是一个真实属性一样。

您可以在模型中创建一个getter:

public function getModelLabel()
{
    return $this->model_year.' '.$this->make.' '.$this->model;
}
然后,您可以在GridView中使用
modelLabel
,就好像它是一个真实的属性一样