Sunday, January 9, 2022

[FIXED] CGridView show columns

Issue

I have a status field, which should be highlighted in green or red, depending on where 0 or 1. I have the following code, but it does not work, all the cells in a single color paint. Tell me how to do such a thing?

array(
            'name' => 'status',
            'htmlOptions' => array('class' => $model->status == 0 ? "non_payed_status" : "payed_status"),
            'filter' => false,
        ),

Solution

You have to override CDataColumn class, look at this, maybe will help:

http://www.yiiframework.com/wiki/314/cgridview-use-special-variable-data-in-the-htmloptions-of-a-column-i-e-evaluate-htmloptions-attribute/



Answered By - user2883814

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.