On Monday, March 26, 2018 at 2:03:06 PM UTC-7, Lee Carmichael wrote: > > I have a question regarding conditionally setting the color of a table > row. What I'm trying to do is similar to this post: > > https://groups.google.com/forum/#!topic/web2py/gy01S0TwF70 > > I guess my lack of experience is keeping me from making the leap from that > scenario to my own. > > My situation is that I have a JSON object that's returned from a REST API > call, rather than a db query. That object that has a field called > "entry_type" and "entry_color". I'm trying to use that to format the table > in my view but i can't figure out if i should edit the CSS to set the color > based on the "entry_type" or maybe simply do something in the view to pull > the color form the JSON. > > It feels like this should be a CSS thing but I'm not sure where and how to > edit the web2py CSS files appropriately. > > Thanks for any tips! >
This isn't a complete answer, but I have this in one of my views: <style> *.odd {background-color: #E5EECC} /* light desert-y green */ *.odd {background-color: #ddffcc} /* light green-bar */ *.odd {background-color: #d0d0f0} /* light blue grey */ </style> It's used in displaying a table, to give that lineprinter paper effect ("green bar"). The order is significant; the last line overrides the other two; depending on my needs, I switch the order around to change the chosen color. It's placed below the {{ extend layout.html }} line, so after all the css files have been read. For a dynamic situation, I'd make set up a css class, and then use javascript to add that classname to the td or tr element. /dps -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.