function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KANTHKANTH 

Applying styles

Display opportunities in the pageblock table.

If stage name is closedwon,display that row in red,

if stagename is closedlost,display that row in green,

if stagename is others,display that row in yellow.

Navatar_DbSupNavatar_DbSup

Hi,

 

Use the below code snippet as reference:

 

---------- Vf page----------------

<apex:page controller="myOppsController" tabStyle="Opportunity">
<apex:form >
<apex:sectionHeader title="Opps List" />
<apex:pageBlock title="" id="pageBlock">
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlockTable value="{!opportunities}" var="o" rendered="{!NOT(ISNULL(opportunities))}">
<apex:column style="{!IF(o.StageName=='Closed Lost','background:lightgreen',IF(o.StageName=='Closed Won','background:red','background:yellow'))}" >{!o.StageName}</apex:column>
<apex:column style="{!IF(o.StageName=='Closed Lost','background:lightgreen',IF(o.StageName=='Closed Won','background:red','background:yellow'))}" >{!o.Name}</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

 

-------- apex controller ---------------
public class myOppsController
{
private List<Opportunity> opportunities;
public List<Opportunity> getOpportunities()
{
opportunities = [Select Name, Amount, Account.Name, CloseDate,StageName from Opportunity];
return opportunities;
}
}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.