Flavio
(Flavioleonelferreira)
July 11, 2010, 9:29pm
1
I´m trying to concatenate column values without success:
<?php $this->widget('zii.widgets.grid.CGridView', array(
...
'columns'=>array(
...
array(
'header'=>'balblal',
'value'=>$model->a.' '.$model->b.' '.$model->b,
),
),
));
is it possible? what am i doing wrong?
whoopass
(Kyleferreira111)
July 11, 2010, 9:32pm
2
I´m trying to concatenate column values without success:
<?php $this->widget('zii.widgets.grid.CGridView', array(
...
'columns'=>array(
...
array(
'header'=>'balblal',
'value'=>$model->a.' '.$model->b.' '.$model->b,
),
),
));
is it possible? what am i doing wrong?
Not sure if it would run into errors with processing through the array but a simple fix is to make a new variable at the top of the widget (before you invoke it):
$newVar = $model->a.$model->b and so on and then use
<?php $this->widget('zii.widgets.grid.CGridView', array(
...
'columns'=>array(
...
array(
'header'=>'balblal',
'value'=>$newVar,
),
),
));
Flavio
(Flavioleonelferreira)
July 11, 2010, 9:48pm
3
whoopass:
Not sure if it would run into errors with processing through the array but a simple fix is to make a new variable at the top of the widget (before you invoke it):
$newVar = $model->a.$model->b and so on and then use
<?php $this->widget('zii.widgets.grid.CGridView', array(
...
'columns'=>array(
...
array(
'header'=>'balblal',
'value'=>$newVar,
),
),
));
it works well with CDetailView, but not with CGridView
whoopass
(Kyleferreira111)
July 11, 2010, 10:03pm
4
What happens in Cgridview as opposed to detailview?
Flavio
(Flavioleonelferreira)
July 11, 2010, 10:13pm
5
display no errors… and a blank column
tri
(tri - Tommy Riboe)
July 11, 2010, 10:41pm
6
Tip:
Use $data->a, $data->b and enclose the complete expression in quotes ("deferred" evaluation when columns are rendered).
/Tommy
Flavio
(Flavioleonelferreira)
July 11, 2010, 11:06pm
7
'value'=>'$data->a.\' \'.$data->b.\' \'.$data->c',
this way worked for me, thanks!
btilley
(Btilley)
June 20, 2012, 5:49pm
8
Question: How would you make this column searchable and sortable in CGridView?
Hi btilley,
You can make this column searchable and sortable by modifying the model class search() method
$data->a.\' \'.$data->b.\' \'.$data->c
$criteria->compare('CONCAT(a,b,c)',$this->a);
nishathul
(Nishathul)
March 22, 2013, 9:56am
10
array(
'header'=>'Name',
'name'=>'first_name',
'value'=>'$data->first_name." ".$data->last_name'
),