Highlight Records based on condition

Example 1:

<apex:page showHeader="false" standardController="testObj__c" recordSetVar="recs" extensions="hilighterExt">
<apex:pageBlock >
    <apex:pageBlockSection >
        <apex:pageblockTable value="{!recs}" var="acc">
            <apex:column headerValue="Name" width="20px">
            <apex:outputlink value="/{!acc.Id}" style="{!IF((acc.testField__c < expDate ),"color:red;","")};"> {!acc.Name} </apex:outputlink>
            </apex:column>
            <apex:column width="30px" headervalue="Exp Date" value="{!acc.testField__c}" style="{!IF((acc.testField__c < expDate ),"color:red;","")}"/> 
        </apex:pageblockTable>
    </apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

public class hilighterExt {
    public Date expDate {get;set;}
    public hilighterExt(ApexPages.StandardSetController controller) {
        expDate = date.newinstance(2015, 01, 01);
        }

}
















Example 2:

<apex:page showHeader="false" Controller="highLightRecordsController" >
<apex:pageBlock >
    <apex:pageBlockSection >
        <apex:pageblockTable value="{!recs}" var="acc">
            <apex:column headerValue="Name" width="20px">
            <apex:outputlink value="/{!acc.Id}" style="{!IF((acc.testField__c < expDate ),"color:red;","")};"> {!acc.Name} </apex:outputlink>
            </apex:column>
            <apex:column width="30px" headervalue="Exp Date" value="{!acc.testField__c}" style="{!IF((acc.testField__c < expDate ),"color:red;","")}"/> 
        </apex:pageblockTable>
    </apex:pageBlockSection>
</apex:pageBlock>

</apex:page>

public class highLightRecordsController {
public List<testObj__c> recs {get;set;}
public Date expDate {get;set;}

public highLightRecordsController () {
recs = new List<testObj__c>();
recs = [SELECT Name,testField__c FROM testObj__c ORDER BY testField__c];
expDate = date.newinstance(2014, 04, 01);
}


}



Comments

Popular posts