CGridView questions

I have the following questions regarding the CGridView:

  1. I wish to combine ‘Category’ and ‘Subcategory’ models in my view. I have created the two separate CGridViews, however the CButtonColumn references the ‘Category’ controller actions by default - how can I make it reference the Subcategory controller actions?

  2. How can I add a heading to the column above the CButtonColumn, for example ‘Actions’.

  3. How can I customize the headings of the existing columns?



By default, it means the ‘update’ action of the current controller.


  2. Same as 2.

Cheers qiang. I did this:


So how can I now append the id= parameter to each of these URLs?

Did you read the property API? It is a PHP expression and you can use $data to refer to the row of data. So you can write something like:


I got one last question for someone to answer. In my table I got a field that stores a multi-value data as such:

Value 1|Value 2|Value 3

I need to display this data in my CGridView, but delimited by a comma.

I tried this:

‘value’=>‘implode(", ", $data->parent_cats)’,

But it just gives a blank cell. Anyone able to advise?

You should first "explode" the values!


'value'=>'implode(", ", explode("|",$data->parent_cats))',

Thanks mdomba, I figured this out too last night!