You need to sign in to do that
Don't have an account?
Nikhil Takawale
How to apply style based on condition in lwc?
Hi,
I have one use case where We want to update the lightning web component to show the "Lowest Cost" column in red if the lowest cost is lower than the Unit cost.
Welcome to your suggestions.
Thanks
Nikhil
I have one use case where We want to update the lightning web component to show the "Lowest Cost" column in red if the lowest cost is lower than the Unit cost.
Welcome to your suggestions.
Thanks
Nikhil
Let's day records variable holding the list of records. Then,
html:
Sorry, it was a type. td should have style not class in this example.
I was able to see your answer as it is same with my requirement.
I tried to replicate your suggestion, but background color does not change based on condition. Can you also check my code?
html file
javascript file Thanks!
Can you print this.actualResults using console.log as last statement in try block. Paste the data here. It will help me understand how the actualResult variable data is framed.
This is the screenshot when I expand it when inspecting the source in chrome.
CAn you please paste SampleController.getAllResult apex code once
Please replace this js file and open chrome console and look for ==data== in the console
Result:
Is this the result you are looking for? Not sure if this helps...
Also, try below code once
This is the current result:
Tried expanding each item, and I can see record data, but can't include here as it already contains some confidential details.
But I checked that some records have less than 100 value so I am expecting the background color to be red. But the console displays otherwise.
Change the code back to
Notice there are only 6 records returned and all are having background color none..
Try below code:
Or
You are great! It is finally working now :) Updating codes to following:
html file:
javascript file:
The variable works instead of the actual API name.
Again, thank you very much for your help and effort in guiding me through it. Really appreciated it :)
Cheers!
Cheers!
Our Web scraping service allows you to scrape data from any websites and transfer web pages into an easy-to-use format such as Excel, CSV, JSON, and many others