css - 如何使用 jqgrid 根据单元格数据应用行样式?

标签 css jqgrid

我的用例如下:

有一个像这样的表:

+------------------------------+
| NOTICE  | This is notice #1  |
| WARNING | This is warning #1 |
| NOTICE  | This is notice #2  |
| ERROR   | This is error  #1  |
+------------------------------+

I'd like to have a specific background color for the whole rows depending of the value of first column.

To implement this, I'd like to make use of a class applied on the row so that I can skin it easily with:

tr.NOTICE td {background-color: Yellow}
tr.WARNING td {background-color: Orange}
tr.ERROR td {background-color: OrangeRed}

不确定是否可以使用 jqGrid,也许使用自定义格式化程序?不知道怎么办

提前致谢

最佳答案

这对我有用:

afterInsertRow:function(rowid, rowdata, rowelem){
  var status = rowdata['status']; 
  if(status=='0'){
   $("tr.jqgrow#"+rowid).addClass("ui-state-error"); 
  }
}

关于css - 如何使用 jqgrid 根据单元格数据应用行样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2036671/

相关文章:

javascript - 无法使用 Lightning 组件 Salesforce 在 Strike Multi Select 元素上滚动

css - 我们可以在已经使用 LESS 作为 css 预处理器的 Angular 1.6.6 中使用 SCSS css 预处理器吗?

jQuery JQGrid 分页事件

jquery - 如何重置先前选择的行并突出显示 JQGrid 中的新行

javascript - 卡住JQgrid分组表第一列

php - Controller 操作被调用两次 --- Php 应用程序

javascript - 如何在不使用 css 转换的情况下将 jQuery animate 与 css3 属性结合起来?

jquery - Bootstrap : sticky footer or affix?

php - jQGrid - 从 Grid1 中选择行以填充 Grid2(MySQL、jQuery、PHP)

javascript - 如何显示刚刚在 jqGrid 中更新的保存值而不重新加载整个网格?