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
srvas137srvas137 

display object records in visualforce page picklist field values wise

display object records in visualforce page picklist field values wise

HariDineshHariDinesh

Hi,

 

Below code sample can display Object records in VFP,

 

apex:page standardController="account"  tabStyle="account" recordSetVar="accounts" sidebar="false">
<apex:pageBlock >
<apex:pageblockTable value="{!accounts}" var="a" >
<apex:column value="{!a.name}"/>
<apex:column value="{!a.AccountNumber}"/>
<apex:column value="{!a.NumberOfEmployees}"/>
<apex:column value="{!a.Rating}"/>
</apex:pageblockTable>
</apex:pageBlock>
  
</apex:page>

 Here what do you mean by Picklist Fieldvise.

Can you explain clearly what you are looking for?

 

I think the above code can be used to get what you are looking for

 

 

srvas137srvas137

no it'snot

actual for picklist  means selectlist in visualforce

selectlist has accountname,account number,phone ,website

like wise we can search

HariDineshHariDinesh

Hi,

 

What are you looking for? Implementing search functionality In VFP or what?

if you can able to spend some time in writing Question it will be easy for Board members to answer you.

srvas137srvas137

yah  i want to implement search functionality in visualforce

 

actual for picklist  means selectlist in visualforce

selectlist has accountname,account number,phone ,website,createddate

like wise we can search

HariDineshHariDinesh

Hi,

 

Yes you can do this Through VFP and APex.

You can use Schema.SobjectType to get the describe information about object, fields and get that into Picklist.

By this you can get all the information regarding the object.

 

// Declare prop to store the selected value
public String selfld{get;set;}
// Declare a property variable in calss
public List<SelectOption> objFields{get; set;} 
// create memore for this like below in mehtod
objFields =new List<SelectOption>();
// add none if needed in Picklist.
objFields.add(new SelectOption('-1','--None--')); 

write below code
Map<String,Schema.SObjectType> ssot = Schema.getGlobalDescribe();
Schema.SObjectType sobjType = ssot.get('objectname__c');
Schema.DescribeSObjectResult dsr = sobjType.getDescribe();
Map<String,Schema.SObjectField> obj = dsr.fields.getMap(); 
for(String fieldName : obj.keyset())  
 {  
   Schema.SObjectField field = obj.get(fieldName);                                          Schema.DescribeFieldResult fieldDesc = field.getDescribe();  
   objFields.add(new SelectOption(fieldName.toLowerCase(),fieldName.toLowerCase()));
   objFields.sort();  
  }

 the VFP code for this picklist:

 

<apex:pageBlockSection id="pbid" title="title" columns="2">
                    <apex:pageBlockSectionItem id="pbsitem">
                        <apex:outputText value="object name"/>  
                        <apex:SelectList id="selde" size="1" value="{!selfld}">
                        <apex:selectOptions value="{!objFields}"/>
                        </apex:SelectList>                    
                    </apex:pageBlockSectionItem>
                                
            </apex:pageBlockSection>

and Below links will be usefull full for you to understand

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_fields_describe.htm

http://boards.developerforce.com/t5/Apex-Code-Development/Best-Way-to-Get-All-Picklists-and-Values-for-an-Object/td-p/363471

 

and for search functionality see below link

 

http://boards.developerforce.com/t5/Visualforce-Development/search-records-in-an-object-and-display-in-visualforce-page/td-p/485597

 

Mark it as Solution if it Answers your Question.