How to alternate GGridView rows to show buttons and dropdown?


I searched the forum for displaying different elements on rows based on the $data->Id but mostly are through CButtonColumn "visible" attribute.

How to display different types other than buttons?

I want show this

Row 1 | image button

Row 2 | image button

Row 3 | dropdown list

Row 4 | image button

I did this but it is not showing the dropdown list



      'template'=>'{showButton} {showDropdown}',		



              'visible'=>'$data->Id != ' . $id,


              'imageUrl'=>Yii::app()->request->baseUrl . '/images/list/move.gif',

              'url'=>'Yii::app()->createUrl("product/", array("listAction" => "showMove", "id" =>$data->Id))',



                'visible'=>'$data->Id == ' . $id,





      'headerHtmlOptions'=>array("class"=>"grid-column-align-center", "width"=>"5px"),      



Hi Joe,

I suggest you review the code CButtonColumn and you will understand a bit more why the above code doesnt work. The buttons() property is an array of buttons, where they are differentiated by IDs (view, update, delete). This is what I would do:

  1. create your own class that extends from CButtonColumn

  2. override its renderButton function to render the buttons you want in the format you want

  3. tell your CGridView to use your extended class ( ‘class’=>‘application.extensions.MYEXTENDEDCLASS’,)


this is great! Thanks for the help Antonio