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
Sindhu NagabhushanSindhu Nagabhushan 

highlight picklist value

Hi,
 
i have the below requirement and i am new to visulaforce. Someone please provide an idea on how to create this.

I want to create a table with all the picklist values available. when i add this VF page to page layout, the corresponding picklist value for that record should be highlighted in my table, Like the image below --
User-added image
Thanks for your help in advance.
hitesh90hitesh90
Hello Sindhu,

Ty to use following sample code. this is for Lead sObject.

Visualforce Page:
<apex:page standardController="Lead" extensions="extleadPicklistVal">
    <table style="border-collapse: collapse;" border="1">
        <tr>
            <th>
                LeadSource
            </th>
        </tr>
    <apex:repeat value="{!lstLeadSource}" var="ls">
        <tr>
            <td style="color:{!If(ls == Lead.LeadSource, 'red;','')}">
                {!ls}
            </td>
        </tr>        
    </apex:repeat>
    </table>
</apex:page>

Apex Class:
public class extleadPicklistVal {
    public List<String> lstLeadSource {get; set;}
    public extleadPicklistVal(ApexPages.StandardController controller) {
        lstLeadSource = new List<String>();
        Schema.DescribeFieldResult fieldResult = Lead.LeadSource.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        for( Schema.PicklistEntry f : ple){        
            lstLeadSource.add(f.getLabel());
        }
    }
}

Thank You,
Hitesh Patel
Email :- hiteshpatel.aspl@gmail.com
http://mrjavascript.blogspot.in/
Sindhu NagabhushanSindhu Nagabhushan
Thank you very much Hitesh.This works fine.

I have to create multiple tables similarly for all picklist fields. Can you help me how to place two tables next to each other?

Thanks in advance.
Sindhu NagabhushanSindhu Nagabhushan
Hi Hitesh,

I am trying to implement your approach for multi-select picklist and its not working. Should we follow a different approach for multi-select picklist?

When i selecy multiple values in my field, values are not getting highlighted.

Thanks in advance