jqGrid Coloring an entire line in Grid based upon a cells value
Posted
by Thomas
on Stack Overflow
See other posts from Stack Overflow
or by Thomas
Published on 2010-05-28T18:56:41Z
Indexed on
2010/05/28
23:02 UTC
Read the original article
Hit count: 966
jqgrid
Hi all,
i know it's been asked before but i cant get it to run and i'm out of things to try.
So i want to colorize a row in a Grid if its value is not 1 - i use a custom formatter for this. The formatter itself works, thats not the problem.
I've tried multple ways I've found so far on the web - adding a class, directly adding css code, using setRowData, using setCell....
Here are my examples - none of them worked for me (linux, ff363) - any pointer would be gratly appreciated.
27.05.2010_00:00:00-27.05.2010_00:00:00 is my row id
<style>
.state_inactive {
background-color: red !important;
}
.state_active {
background-color: green !important;
}
</style>
function format_state (cellvalue, options, rowObject)
{
var elem='#'+options.gid;
if (cellvalue != 1) {
jQuery('#list2').setRowData(options.rowID,'',
{'background-color':'#FF6F6F'});
jQuery('#list2').setRowData('27.05.2010_00:00:00-27.05.2010_00:00:00',
'',{'background-color':'#FF6F6F'});
for (var cnt=0;cnt<rowObject.length;cnt=cnt+1) {
jQuery(elem).setCell(options.rowId,cnt,'','state_inactive','');
jQuery(elem).setCell('"'+options.rowId+'"',cnt,'','state_inactive');
jQuery(elem).setCell('"'+options.rowId+'"',cnt,'5',
{'background-color':'#FF6F6F'},'');
}
} else {
for (var cnt=0;cnt<rowObject.length;cnt=cnt+1) {
jQuery(elem).setCell(options.rowId,cnt,'','state_active','');
}
}
<!-- dont modify, we simply added the class above-->
return cellvalue;
}
Thanks, Thomas
© Stack Overflow or respective owner