Adding button in CGridView

Hi to all again ^^, i have a new doubt, i want add a new button on CGridView provided for admin.php (script generated by CRUD generate), the code of this is the next:




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

	'id'=>'curriculum-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

		'id',

		'id_persona',

		'data_entrada',

		'com_ha_arribat',

		'nota',

		'observacions',

		/*

		'interessant',

		'actiu',

		*/

		array(

			'class'=>'CButtonColumn',

		),

	),

)); ?>



I guess is adding something down of ‘class’ => ‘CButtonColumn’, but i dont know how and if this is posible. I want this because i want go to another form of another model with this id. e. g:

I have a model: person and cars

i want in the admin of person ‘click’ in a button of one person and go to a create form of cars with the id of this person.

Grettings and thanks,

s0mk3

You can do some thing like this





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

        'id'=>'curriculum-grid',

        'dataProvider'=>$model->search(),

        'filter'=>$model,

        'columns'=>array(

                'id',

                'id_persona',

                'data_entrada',

                'com_ha_arribat',

                'nota',

                'observacions',

                /*

                'interessant',

                'actiu',

                */

		'link'=>array(

			'header'=>'Go to...',

			'type'=>'raw',

			'value'=> 'CHtml::button("button label",array("onclick"=>"document.location.href=\'".Yii::app()->controller->createUrl("controller/action",array("id"=>$data->id))."\'"))',

		),				

                array(

                        'class'=>'CButtonColumn',

                ),

        ),

	)); ?>




CButtonColumn::template and CButtonColumn::buttons are the keys.




	array(

		'class' => 'CButtonColumn',

		'template' => '{view} {update} {delete} {copy}',

		'buttons'=>array(

			'copy' => array(

				'label'=>'Copy', // text label of the button

				'url'=>"CHtml::normalizeUrl(array('copy', 'id'=>\$data->id))",

				'imageUrl'=>'/path/to/copy.gif',  // image URL of the button. If not set or false, a text link is used

				'options' => array('class'=>'copy'), // HTML options for the button

			),

		),

	),



First, add some button name to the template. I added ‘copy’ button.

If you don’t want some of the default buttons (i.e. view, update and delete), you may omit it.

Second, define the properties of the button that you added. I defined label, url, image and html options.

All the information regarding this could be retrieved from the reference manual. :)

Check CButtonColumn

Thanks for your reply, this is what i wanted!!! Thanks Sadaf too, but your reply dont is what i wanted…

I Want to add checkbox Button in "CButtonColumn".

Help me to do that?