4
我需要在CGridView中添加一列。如何在YII中的CGridView中添加自定義列?
我用這個:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'user-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'pager' => array(
'firstPageLabel' => '<<',
),
'columns'=>array(
'username',
'name',
'email',
'creationDate',
array(
'class' => 'CButtonColumn',
'template' => '{change} {view}',
'buttons' => array(
'change' => array(
'url'=> "'http://test.com/userservice/".$model->username."'",
),
),
),
array(
'name' => 'test',
'value' => 'testtest',
)
),
));
但我得到的錯誤:
Property "User.test" is not defined.
Look [using-standard-filters-in-cgridview-custom-fields](http://www.yiiframework.com/wiki/117/using-standard-filters-in-cgridview-custom-fields /),瞭解更多信息。 – shgnInc