如何根据jqgrid中的单元格值设置单元格背景颜色? [英] how to set the cell background color baced on the cell value in jqgrid?
问题描述
我正在使用 jqgrid.我需要根据值设置单元格的背景颜色.
I'm using jqgrid. I need to set background color of the cell based on the values.
我在重新加载颜色被禁用的表格后尝试使用以下代码.
I have tried using the following code after reload the table the color is disabled.
jQuery("#list").setCell('5','5','t',{背景:'#ff0000'});
jQuery("#list").setCell ('5','5','t',{background:'#ff0000'});
我想在表格加载时根据单元格值设置单元格背景颜色.如何做到这一点?
I want to set the cell background color on table loading, based on the cell values. how to do this?
提前致谢.
推荐答案
您可以通过多种方式做到这一点:请参阅 这个,this 或 这个.重要的不仅是您如何执行此操作,还在于在哪里.loadComplete
事件句柄是很好的地方.
You can do this in many ways: see this, this or this. Important is not only how you do this, but where. The loadComplete
event handle is the good place for that.
更新:在 jqGrid 的下一个版本中,您将能够使用新的 cellattr
选项作为 colModel
中的函数.请参阅 此演示 和 我原来的建议.
UPDATED: In the next version of jqGrid you will able to use new cellattr
option as function in the colModel
. See this demo and my original suggestion.
这篇关于如何根据jqgrid中的单元格值设置单元格背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!