Labels In Cgridview

I’m using a CGridView widget in my view file

where some of the columns are showing data from related tables


$this->widget('zii.widgets.grid.CGridView', array(



			array('name' => 'Field1', 'value' => '$data->Field1'),

			array('name' => 'xxxx', 'value' => '$data->requestREL->RelatedField'),



where Field1 is from current model ,

RelatedField is a field defined in the related model,

and requestREL is the name of the relationship defined in the current model.

The problem is with the labeling.

While Field1 gets its appropriated name from function:attributeLabels,defined inside

his model , I can’t find a way to print a label for the related table field( e.g. RelatedField).

I tried to make a new entry in function:attributeLabels , with the desired label , but then,

in the Grid, the label isn’t a hyperlink with sorting mechanism etc. like the default fields

(not to mention that its font color is white and I have to change it via CSS to show up)

Any ideas ?

you can add headers explicitly in grid definition:

$this->widget('zii.widgets.grid.CGridView', array(



                        array('name' => 'Field1', 'value' => '$data->Field1', 'header'=>'my header'),

                        array('name' => 'xxxx', 'value' => '$data->requestREL->RelatedField', 'header'=>'my header'),




Thanks a lot about the tip , didn’t know that.

But it stil shows up with font color in white and without any functionality.


read this:

Also this may helps you

Thanx a lot guys for the replies and sorry for the delay.