Issue
[
'class'=>'\kartik\grid\DataColumn',
'attribute'=>'bumi_status',
'value'=>function($model,$url){
if($model->bumi_status == 'Bumi')
{
//return 'Yes';
return '<span class="glyphicon glyphicon-ok"></span>';
}
else
{
return '<span class="glyphicon glyphicon-remove"></span>';
}
}
],
I would like to return a glyhpicon instead of word inside the column but now it showing the full sentence. Anyway how to make it show the icon?
Solution
You just need to add: 'format' => 'raw'
:
[
'class'=>'\kartik\grid\DataColumn',
'attribute'=>'bumi_status',
'format' => 'raw',
'value'=>function($model,$url){
if($model->bumi_status == 'Bumi')
{
//return 'Yes';
return '<span class="glyphicon glyphicon-ok"></span>';
}
else
{
return '<span class="glyphicon glyphicon-remove"></span>';
}
}
],
As described in the docs:
In which format should the value of each data model be displayed as (e.g. "raw", "text", "html", ['date', 'php:Y-m-d']). Supported formats are determined by the formatter used by the yii\grid\GridView. Default format is "text" which will format the value as an HTML-encoded plain text when yii\i18n\Formatter is used as the formatter of the GridView.
The default is text
so Yii format it as HTML-encoded, and it formats the value. If the format is raw
it just display the value as is.
Answered By - Ziki
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.