php - 想根据表格中的某个字段显示CGridview,并在显示时区分它们?

标签 php css yii

I have CGridview which consists of list of messages, I want to distinguish it by read and unread by color change in grid, I am not good in CSS so I don' t have any Idea about it?

最佳答案

  1. 在main.css中添加

    .grid-view table.items tr.unread {
        background: none repeat scroll 0 0 #FF0000 !important; /* red color is unread */
     }
    
    .grid-view table.items tr.read {
        background: none repeat scroll 0 0 #00FF00 !important; /* green color is read */
    }
    
  2. 在消息模型中

    function isRead()
    {
        return $this->hasRead;
    }
    
  3. 在 CGridView 中添加行 css 类表达式

    'rowCssClassExpression' => '$data->isRead()?"read":"unread"',
    

关于php - 想根据表格中的某个字段显示CGridview,并在显示时区分它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12381084/

相关文章:

php - 突出显示或着色使用 PHP 和 Mysql 获取的表中特定行的值

php - 如何在 yii 中编写带有连接的查询?

php - 无法在 Yii2 中使用迁移添加新表

yii - 在 yii2 表格小部件中显示时合并两列

php - 使用 GD 库和文本时左侧出现烦人的空格

php - 启动 : Unable to load dynamic library '/usr/lib/php/modules/module.so'

当 mysql 死机时,php 重新加载页面

jquery - scrollTop() 不适用于滚动 :touch

html - 列表的宽度比应该的大

css - 基础粘性元素无视 float 类