0

I have requirement that need to display section title back ground color based on multiple conditional expression

for example i have account name as section header so i want to display section header back ground color Red if there is any open opportunities are available or Green if account status active else nothing

style = "{!v.Custom_object__c.Account___r.Total_Open_Opportunities__c > 0 ?'rgb(135, 5, 0)':''}"  
2
  • what error you are getting? – Ashwani Sep 29 '16 at 11:28
  • no i dint get any error, am not aware of logic to apply it. – Raj_SFDC Sep 29 '16 at 12:15
2

This is very much doable.

Since you haven't given any specific information about how you are holding the list of opportunity, I am assuming you have a list of opportunity in aura:attribute named oppList. And Account is stored in acc aura:attribute.

You need the following ternary operator in your style attribute of div. You can have nested operators as well like this.

<div style="{!v.oppList.length > 0 ? 'background:red;': (v.acc.isActive ? 'background:green;' : '')}">
...
</div>
1
  • Thank you it is working fine, i have tried in another way using '||' condition – Raj_SFDC Sep 29 '16 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.