• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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: 557
10
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: 67590
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: 24321
167
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...

 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic