This week's book giveaway is in the Cloud forum.
We're giving away four copies of Terraform in Action and have Scott Winkler on-line!
See this thread for details.
Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Make specific color for a row based on row's property

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a requirement to highlight rows with specific color based on its attribute. For example, let's say I am displaying employee records and all employees whose highest education column is not null then show it with green

I have the existing code as following in the corresponding employee.component.html file



so as of now, only a specific column is colored but the requirement is to color the whole row? I am using Angular 10.x. I am trying to use some kind of logic on starting "tr" tag but its not working.
 
Bartender
Posts: 567
14
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
bgcolor is deprecated.

The docs say you should use background-color now.

 
Sheriff
Posts: 67601
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This has nothing at all to do with Angular. It's straight-forward HTML (hence it has been moved to the HTML forum).

You should use CSS for styling, not HTML attributes. And, if you want the row background colored, put the styling on the <tr> element.
 
Saloon Keeper
Posts: 24587
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To expound on Bear, If you can generate a row in the format:

and substitute class names like "no_education", "high_school", "college" and so forth then you can have a very fine degree of control indeed and it's much more straightforward to boot.

Sorry I couldn't give the precise way to do it in Angular, but I'm not knowledgeable on that platform. JavaServer Faces, PHP, or Node Express, on the other hand...

 
reply
    Bookmark Topic Watch Topic
  • New Topic