How To Change Default Delete Button's Style In Gridview

Hi All,

I would like to change the delete button’s apariance showed in the gridview. I have tried several things but not working…

This is what the button looks like now:




<td href="/yii4/htdocs/index.php/blog/postmedia/ajaxdelete/id/PostMedia">

    <a class="btn btn-danger" href="/yii4/htdocs/index.php/blog/postmedia/ajaxdelete/id/112" rel="tooltip" title="Remove">

        <i class="icon-trash"></i>

    </a>

</td>



and I want to get this:




<td href="/yii4/htdocs/index.php/blog/postmedia/ajaxdelete/id/PostMedia">

    <a class="btn btn-danger" href="/yii4/htdocs/index.php/blog/postmedia/ajaxdelete/id/112" rel="tooltip" title="Remove">

        <i class="icon-trash icon-white"></i>

        Remove

    </a>

</td>



If I try to modify the default delete button, I can’t put the lable “Remove” and I can’t change the icon class.

If I try to add a custom button, then… I can’t add a icon class inside <a> tags and also the call action doesn’t work as expected because it’s not a POST request (I don’t know why)

Here is what I have tried:




array('class'=>'bootstrap.widgets.TbButtonColumn',

    'template'=>'{delete} {remove}',			

    'deleteButtonLabel' => 'Remove',

    //'cssClassExpression' => 'CHtml::tag("i", array("class" => "icon-trash icon-white"),"")',

    'deleteButtonOptions' => array ('class'=>'btn btn-danger',

    ),

    'deleteButtonUrl'=>'Yii::app()->createUrl("/blog/postmedia/ajaxdelete", array("id"=>$data["id"]))',

    'htmlOptions'=>array(

        'href'=>Yii::app()->createUrl('/blog/postmedia/ajaxdelete', array('id'=>$model->id,)),

    ),

			 

    'buttons' => array(

        'remove' => array(

            'label'=>'Remove',     

                'url'=>'Yii::app()->createUrl("/blog/postmedia/ajaxdelete", array("id"=>$data["id"]))',			

                'options'=>array(

                    'href'=>Yii::app()->createUrl('/blog/postmedia/ajaxdelete', array('id'=>$model->id,)),

                    'class'=>'btn btn-danger',

                ),					    		

         ),

     ),

),



I would appreciate some help, thanks a lot!

Hi, i think you can use imageUrl to set the appearance.

An example of customised button:




'class'=>'CButtonColumn',

	'htmlOptions' => array('style'=>'width:80px'), 

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

      	'buttons' => array(

	   'export' => array(

              	'label'=>'Export', 

               	'imageUrl'=>'',   

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

               	'url'=>'Yii::app()->createUrl("Groups/ExportGroup", array("id"=>$data->group_id))', 

           ),

...



Hi Ragua,

Thanks for your reply, the problem is that I don’t have the icon stored as a independet file, but as a css class, in mi case:


<i class="icon-trash icon-white"></i>



That’s why I need to change the i class, some idea?