How to alternate GGridView rows to show buttons and dropdown?

Hi

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




    array(

      'class'=>'CButtonColumn',

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

       'buttons'=>array(

          'showButton'=>array(

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

              'label'=>'move',

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

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

            ),

            'showDropdown'=>array(

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

                'type'=>'raw',

                'value'=>$strMyDropDownTreeInHtmlode,

              ),               

          ),  

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

      ),



Thanks

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’,)

Cheers

this is great! Thanks for the help Antonio