gerilla
(Deli Palta)
October 18, 2013, 2:42pm
1
hi,
i create a relationship with customer and income tables. it works ok. i can show name values at income cgridview:
array('name'=>'customer','value'=>'$data->customer->name',),
but i need show name and surname values in a single column in income cgridview.
array('name'=>'customer','value'=>'$data->customer->name $data->customer->surname',),
this doesnt work.
any help?
Keith
(Kburton)
October 18, 2013, 3:37pm
2
array('name'=>'customer','value'=>'$data->customer->name . " " . $data->customer->surname',),
Hi,
You can access the controller in this way inside grid
[color="#800000 "]$this->grid->controller[/color]
[color="#800000 "]Write this method in controller[/color]
[color="#000088 "]public[/color] [color="#000088 "]function[/color][color="#000000 "] getFullname[/color]color="#666600" {[/color] [color="#000088 "] return[/color][color="#000000 "] $this[/color][color="#666600 "]->[/color][color="#000000 "]customer[/color][color="#666600 "]->[/color][color="#000000 "]name [/color][color="#666600 "].[/color] [color="#008800 "]’ '[/color] [color="#666600 "].[/color][color="#000000 "] $[/color][color="#000088 "]this[/color][color="#666600 "]->customer->[/color][color="#000000 "]surname[/color][color="#666600 "];[/color] [color="#666600 "]}[/color]
[color="#666600 "]In view u can access[/color]
[color="#000000 "]array[/color]color="#666600" ,[/color]
gerilla
(Deli Palta)
October 19, 2013, 8:54am
4
thanks it works. thanks for other replies, too.
but i have another trouble now. when i enter name in filter input it finds customer, but when i enter surname in filter inputbox at cgridview, it cant find customer, cos it searches at only name in search criteria in model file:
$criteria->compare('customer.name',$this->mid);
how can i add name with surname to search criteria?
gerilla
(Deli Palta)
October 19, 2013, 9:13am
5
ok i made it. i add this code in model search func. and it works:
$criteria->compare('customer.name',$this->mid);
$criteria->addSearchCondition('customer.surname',$this->mid,'true','OR');