jQuery jqgrid 设置单元格背景色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1302006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 11:09:59  来源:igfitidea点击:

Jqgrid set cell background color

jquerycolorsjqgrid

提问by Jon Weers

In "Custom data tooltips in jqGrid 3.4" discussion, came to know how to use setcellto change the color of the text inside a cell of jqgrid. How can we change the background color of the cell?

在“ jqGrid 3.4中的自定义数据工具提示”讨论中,知道了如何使用setcell来改变jqgrid单元格内文本的颜色。我们如何更改单元格的背景颜色?

Tried the following

尝试了以下

jQuery("#list").setCell (row,col,'',{ background-color:'red'});

jQuery("#list").setCell (row,col,'','',{ bgcolor:'red'};

回答by Jon Weers

Use backgroundinstead of specific rules like background-color:

使用背景而不是像背景颜色这样的特定规则:

jQuery("#list").setCell (row,col,val,{background:'#ff0000'});

回答by Aaron Baker

jQuery("#list").setCell (row,col,'',{ 'background-color':'red'})

This did not work in IE for me (fine in firefox and chrome), so I did what Jon Weers suggested and switched to:

这对我来说在 IE 中不起作用(在 firefox 和 chrome 中很好),所以我做了 Jon Weers 的建议并切换到:

jQuery("#list").setCell (row,col,'',{'background':'#ff0000'});

and this worked in firefox, chrome, and IE for me.

这对我来说在 firefox、chrome 和 IE 中都有效。

Sorry, my account is too new to vote up, or apparently comment, otherwise I'd simply vote up Jon's post.

抱歉,我的帐户太新,无法投票或发表评论,否则我只会投票支持 Jon 的帖子。

回答by Daniel Moura

jQuery('#list').setCell('12','name','',{'background-color': 'red'},'');

Are you putting the right row id? The right colName?

您是否输入了正确的行 ID?正确的 colName?

You are also missing the quotes in background-color.

您还缺少背景颜色中的引号。