How to add a name to CButtonColumn

While working with CGridView, I want to add a title to CButtonColumn. Please help because ‘name’ property is not working.

Try label property.

Happy coding.

Yes lable will work, find below code with customize button,

you can give url, image… … to customize button.

You can find what you want,


array(

			'class'=>'CButtonColumn',

			'template'=>'{Approve} {Pending} {Reject}',

			'buttons'=>array

  	  		(

  	  		         'Approve' => array

	    			(

	        			'label'=>'Approve',	// your solution here

	        			'imageUrl'=>Yii::app()->request->baseUrl.'/images/approve.png',

	        			'url'=>'Yii::app()->createUrl("controller/method", array("param1"=>"Param 1"))',	           	

	    			),

                	....

                	....

But i want to give a name to the column… like ‘Action’

In that case, use the header property like for any CGridColumn, like this:


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

    'id'=>'some-grid',

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

    'columns'=>array(

        …

        array(

            'class' => 'CButtonColumn',

            'header' => 'Some Title',

            …

        ),

    ),

));

Samrat, next time check http://www.yiiframework.com/doc/api/1.1/CGridView.

Happy coding.