You are viewing revision #3 of this wiki article.
This version may not be up to date with the latest version.
You may want to view the differences to the latest version or see the changes made in this revision.
Hi buddies !, This tutorial shows about how to add a custom button with your own icon for your CGridView of Yii framework
Step 1 Add a new array element under 'class' => 'CButtonColumn' as follow The default buttons are
'template' => '{view}{update}{delete}',
Now I am adding a new button for reply
'template' => '{reply}{view}{update}{delete}',
Step 2 Then add a new element in the name reply under button array as follows
'buttons' => array(
'reply' => array( //the name {reply} must be same
'label' => 'Reply', // text label of the button
'url' => 'CHtml::normalizeUrl(array("dashboard/mail/id/".rawurlencode($data->feedback_email)."/f_id/".$data->feedback_id))', //Your URL According to your wish
'imageUrl' => Yii::app()->baseUrl . '/images/reply_mail_icon.png', // image URL of the button. If not set or false, a text link is used, The image must be 16X16 pixels
),
),
For more field definitions of buttons array check CButtonColumn
With bootstrap
You can also use bootstrap icons.
The way for it is easy.
'buttonID' => array( 'label'=>'<span class="icon-plus"></span>', //put the span at label with icon class 'url'=>'...', // 'imageUrl'=>'...', coment the propriety imageUrl 'options'=>array('title'=>'Add 1 more'), // put here the title to show when mouse over 'click'=>'...', 'visible'=>'...', )
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.