Activity › Forums › Salesforce® Discussions › Display list in visualforce page
Tagged: List, Salesforce Apex, Salesforce Visualforce Page
-
Display list in visualforce page
Posted by Ajay Prakash on April 30, 2016 at 5:36 PMI have n number of list, I have to display each list in n number of column of a table.How should I proceed ?
Thanks in advance
shariq replied 8 years, 10 months ago 3 Members · 2 Replies -
2 Replies
-
you can try doing as below:
Apex :
public Boolean showRecords{get;set;}<br>public List<CustomObject__c> cust {get;set;}<br>//In constructor<br>showRecords =false;<br>public void fetchRecords(){
cust = [Select Field1__c, Field2__c from CustomObject__c limit 1000];// you need to place a limit of 1000 as VF supports max of 1000 recors to be displayed<br>showRecords = true;<br>}VFP:
<apex:pageblock><br><apex:commandButton value=”List Records” action=”{!fetchRecords}” rerender=”pbTable”/>
<apex:pageblocktable value=”{!cust}” var=”a” id=”pbTable” rendered=”{!showRecords}”>
<apex:column value=”{!a.Field1__c}”/>
<apex:column value=”{!a.Field2__c}”/>
</apex:pageblocktable >
</apex:pageblock> - [adinserter block='9']
-
Hi Ajay,
you can try this :-
Apex
public class Records
{
public List con {get;set;}
public void search()
{
con = [SELECT LastName, Id FROM Contact LIMIT 100];
}
}Visualforce Page
<apex:page controller = “Records”>
<apex:form>
<apex:pageBlock>
<apex:commandButton value = “records” action = “{!search}”/>
<apex:pageBlockTable value=”{!con}” var = “contact”>
<apex:column value = “{!contact.LastName}”/>
<apex:column value = “{!contact.Id}”/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Log In to reply.