Activity Forums Salesforce® Discussions Display list in visualforce page Reply To: 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>