I have used the BaseCellRenderer to color individual cells based on conditions and it had worked great for me.
Now I need to color a whole row whenever a condition is met on one of its cells.
Is there some type of Row Renderer I can use to color the table row? If not, what would be the best way to accomplish this?
This is a little complicated because the cell is not put into the DOM so you cannot move up to the parent to style it.
You can do it with some complicated CSS though. Here's how:
Add application CSS (in dashboard.css or application.css) that will use adjacent sibling selectors to style the TD elements based on the class in the first cell. The CSS would look something like this (assuming that your cell renderer applies the class "makerowred" to the first cell):
/* styles the first cell */
td.makerowred{
color: red;
}
/* styles the second cell */
td.makerowred + td{
color: red;
}
/* styles the third cell */
td.makerowred + td + td{
color: red;
}
This is a little complicated because the cell is not put into the DOM so you cannot move up to the parent to style it.
You can do it with some complicated CSS though. Here's how:
Add application CSS (in dashboard.css or application.css) that will use adjacent sibling selectors to style the TD elements based on the class in the first cell. The CSS would look something like this (assuming that your cell renderer applies the class "makerowred" to the first cell):
/* styles the first cell */
td.makerowred{
color: red;
}
/* styles the second cell */
td.makerowred + td{
color: red;
}
/* styles the third cell */
td.makerowred + td + td{
color: red;
}
Bugger, sounds as if the renderer is getting the td before it's been hung into the DOM tree... and there's no parent selector in CSS either.
You could move the getting and CSS'ing of the parent into a delayed function, but that'd be quite ugly programming practice. Might work as a QnD temporary solution though.
I tried to get a hold of its parent using .parent() and .closest('tr') functions, but neither worked. I debugged using chrome and it seems like $td has no parent. Is there some other way to get its parent?
Your JS renderer does have access to the td element, right? If so you may be able to grab hold of its parent, the tr element, and set its CSS or class attributes.
No, I am using simple xml with
Are you using Django bindings?