I know it's been asked before, but I cant get it to run and I'm out of things to try.
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, that's not the problem.
I've tried multiple 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 greatly 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;
}
Very Simple and works
Assumed other cell value is Y/N.
below code goes in loadComplete event
for anyone that looking for a real answer at this topic..
this works !
In another file stylesheet the custom CSS
dont forget the !important to overwrites the theme ui roller
It seems to me that your main problem is you're not setting a 'background-color' style. You should remove 'ui-widget-content' class from the row (from
<tr>
element)before adding the class
state_activ
orstate_inactive
, because jQuery UI class 'ui-widget-content' is define.ui-widget-content
likeand only with setting of CSS
'background-color'
your not really change the background color. So try to use something likeI suggest that you try someing like this. This will actualy give you access to the whole row.
I've tried solutions above, but I think that one is the correct:
If css class is between apostrophes, then it is overwritten by to the original one (you can see that easily using firebug):
correct with {color:'red'}:
According to documentation of setRowData: