Activity Forums Salesforce® Discussions Display list in visualforce page

  • Gourav

    Member
    May 30, 2016 at 11:35 am

    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>

  • shariq

    Member
    July 18, 2017 at 10:56 am

    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>

    • This reply was modified 7 years, 4 months ago by  shariq.
    • This reply was modified 7 years, 4 months ago by  shariq.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos