Yii Framework Forum: How To Change Default Delete Button's Style In Gridview - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Change Default Delete Button's Style In Gridview Rate Topic: -----

#1 User is offline   menxaca 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 121
  • Joined: 26-November 12
  • Location:Talavera de la Reina, Spain

Posted 18 March 2013 - 09:06 PM

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!
0

#2 User is offline   ragua 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 135
  • Joined: 23-January 12
  • Location:Paris - France

Posted 19 March 2013 - 03:16 AM

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))', 
           ),
...

0

#3 User is offline   menxaca 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 121
  • Joined: 26-November 12
  • Location:Talavera de la Reina, Spain

Posted 19 March 2013 - 06:38 AM

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?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users