I need to add a column in CGridView.
I use this:
$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',
)
),
));
But I got error:
Property "User.test" is not defined.
You're almost there, in your column array you would use the name
param for attributes of the model in the dataprovider, instead for custom columns you can use header
like so:
'columns'=>array(
...
array(
'header' => 'test',
'value' => '"testtest"',
),
...
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With