我在$(document).ready(
$("#stSearchTermsGrid").setCell(2, 2, '', {color:'red'}) ;
但这不起作用。我是用错误的方式写的还是放在错误的地方。
我知道这个问题已经被问过不止一次了,这就是我获得第一行的方式。但是我仍然无法做到这一点,也不知道问题出在哪里。
最佳答案
您是对的,您不是第一个提出问题的人。为了清除单元格颜色的情况,我做了the demo
为您提供了不同的更改单元格文本颜色或卖方背景颜色的方法:
loadComplete: function() {
// 2 is zero-base index of the column 'name' ('Client'). Every from the options
// multiselect:true, rownumbers:true and subGrid:true will increase
// the index by 1 because the option inserts additional columns
$("#6 td:eq(2)", grid[0]).css({color:'red'});
grid.jqGrid('setCell',"12","name","",{color:'red'});
grid.jqGrid('setCell',"10",'name', '', 'my-highlight');
grid.jqGrid('setCell',"8",'name', '', 'ui-state-error ui-state-error-text');
grid.jqGrid('setCell',"4","name","",{'background-color':'yellow',
'background-image':'none'});
grid.jqGrid('setCell',"3","name","",'ui-state-highlight');
}
哪里
<style type="text/css">
.my-highlight { color: red; }
</style>
和“ 3”,“ 4”,“ 6”,“ 8”,“ 10”和“ 12”是将更改相应列的颜色的行的rowid。
顺便说一句,我个人最喜欢的是使用
更新:为了了解在使用另一个jQuery UI主题的情况下不同方法的使用差异,我添加了jQuery UI Themes使用La Frog Theme,其中与上述相同的表格如下所示:
关于jquery-ui - 如何更改jqGrid单元格的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4942761/