[英]Yii CGridView assign class on data value
我对Yii更重要,并尝试制作一个应用程序。
在我看来我正在使用
zii.widgets.grid.CGridView
我有一个colum取代结果如下
array(
'name' => 'name',
'value' => 'CHtml::link("<span class=\"label label-success\">".$data->getStatus()."</span> ".$data->name."<br> View Status <br> Copy Draft)',
'type' => 'raw',
),
这里我有<span class=
,我想改变SPAN
class
依赖于$data->getStatus()
,就像Status is Draft
,我想把类分配为Label Warning
,当Status is Sent
我想要分配类label label-success
我怎样才能做到这一点 ?
谢谢
您可以在CActiveRecord中添加功能
class YourClasseModel extends CActiveRecord
{
public function renderYourValue($data,$row)
{
if ($data->getStatus == 'Sent') {
return CHtml::link("<span class=\"label label-success\">".$data->getStatus()."</span> ".$data->name."<br> View Status <br> Copy Draft");
}
if ($data->getStatus == 'Draft')
}
.......
'value'=>array($model,'renderYourValue'),
并调用列中的函数
array(
'name' => 'name',
'value' => 'value'=>array($model,'renderYourValue'),
'type' => 'raw',
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.