Salesforce: Dynamically Assign the Salesforce standard icons in the Visualforce page
//VF Page code
//Apex Class to get the values
<apex:pageBlockTable value="{!recordList}" var="record">
<apex:column headerValue="Icon">
<apex:image id="theImage" value="{!record.colorCode}"/>
</apex:column>
</apex:pageBlockTable>
//Apex Class to get the values
public List<accountRecord> recordList {get; set;}
public void getAccount() {
recordList = new List<accountRecord>();
for(Account record:[SELECT CreatedDate FROM Account]) {
String colorCode = (record.CreatedDate>System.Now().addDays(-3))?'/img/samples/flag_green.gif':(record.CreatedDate>System.Now().addDays(-5))?'/img/samples/flag_yellow.gif':'/img/samples/flag_red.gif';
recordList.add(new accountRecord(colorCode));
}
}
public class accountRecord {
public String colorCode { get; set; }
public kbArticleRecordWrapper(String colorCode) {
this.colorCode = colorCode;
}
}
Comments
Post a Comment