Activity Forums Salesforce® Discussions display more records beyond the supported limit on the VF page in salesforce

  • shradha jain

    Member
    September 4, 2018 at 11:04 am

    Hello Madhulika,

    To display more records beyond the supported limit on the VF page you need to enable readOnly attribute value as true for the page tag so that -

    • Number of query rows will increased from 50000 to 1 million rows.
    • Number of records displayed on VF page will be increased from 1000 to 10000
  • Neha

    Member
    September 4, 2018 at 11:19 am

    Hi Madhulika,

    If we want to show more records than 50,000 then we have the following two options:

    1. We can enable readOnly attribute value as true
    2. Or we can implement pagination in our pages

    Example: Retrieving Data in Apex to Paginate with the StandardSetController
    public class opportunityList {
    public ApexPages.StandardSetController setCon {
    get {
    if(setCon == null) {
    setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
    [SELECT Name, StageName, Amount, Account.Name, Account.Named_Account__c FROM Opportunity where Account.BillingState = ‘California’ and Status__c = ‘Open’]));
    }
    return setCon;
    }
    set;
    }

    // Initialize setCon and return a list of records
    public List getOpportunities() {
    return (List) setCon.getRecords();
    }
    }

    Note: we can also do pagination using offset caluse in SOQL query.

  • shariq

    Member
    September 17, 2018 at 9:20 pm

    Hi,

    Pagination is the best option -

    Try this  -

    Visual Force Page:

     

    <apex:outputLabel ><B>Showing {!pageNum} page out of {!totPages} pages and your viewing from {!index} record to {!pagevalue} out of Total {!totalRecs} </B></apex:outputLabel>
    <c:PageBlockTableEnhancerADV targetPbTableIds="mid,mid2" paginate="true" defaultPageSize="600" pageSizeOptions="100,400,600,700,900,1000"/>
    <apex:pageblockTable value="{!tempMemb}" var="m" id="mid">

    <apex:column > <apex:inputText value="{!m.Name}"> </apex:inputText> </apex:column>
    <apex:column value="{!m.id}"/>
    <apex:column value="{!m.Name}"/>

    </apex:pageblockTable>
    <apex:pageblockButtons >
    <apex:commandButton value="First" rerender="details" action="{!beginning}" disabled="{!prev}" oncomplete="initPageBlockTableEnhancerADV()"/>
    <apex:commandButton value="Prev" rerender="details" action="{!previous}" disabled="{!prev}" oncomplete="initPageBlockTableEnhancerADV()"/>
    <apex:commandButton value="Next" rerender="details" action="{!next}" disabled="{!nxt}" oncomplete="initPageBlockTableEnhancerADV()"/>
    <apex:commandButton value="Last" rerender="details" action="{!end}" disabled="{!nxt}" oncomplete="initPageBlockTableEnhancerADV()"/>
    <apex:commandButton value="Mass Update" reRender="details" action="{!massUpdate}" status="Load" oncomplete="initPageBlockTableEnhancerADV()"/>
    </apex:pageblockButtons>

    <apex:actionStatus id="Load"> Loading........</apex:actionStatus>

    </apex:pageBlock>
     

    Controller:

     

    public class PaginationCtrl2
    {
    public integer totalRecs{get;set;}
    public integer index {get;set;}
    public integer blockSize{get;set;}
    public integer pagevalue{get;set;}
    public integer pageNum{get;set;}
    public integer totPages{get;set;}
    public list<review__c> tempMemb{get;set;}

    public PaginationCtrl2()
    {
    tempMemb=new List<review__c>();
    totalRecs = 0;
    index = 0;
    pageNum =1;
    blockSize = 1000;
    pagevalue = 1000;
    totalRecs = [select count() from review__c];
    totPages = (totalRecs /1000)+1;
    gettempMemb();
    }

    public List<review__c> gettempMemb()
    {
    tempMemb=Database.Query('SELECT id,Name FROM review__c LIMIT :blockSize OFFSET :index');
    return tempMemb;
    }

    public void beginning()
    {
    index = 0;
    pagevalue = index +1000;
    pageNum =0;

    gettempMemb();
    }

    public void previous()
    {
    pagevalue = index;
    index = index - blockSize;
    pageNum = (pageNum -1)==-1?0:pageNum-1;

    gettempMemb();
    }

    public void next()
    {
    index = index + blockSize;
    pagevalue = (index +1000)>totalRecs ?totalRecs :(index +1000);
    pageNum = (pageNum == totPages || pageNum+1>totPages) ?totPages :pageNum+1;
    gettempMemb();
    }

    public void end()
    {
    index = totalrecs - math.mod(totalRecs,blockSize);
    pagevalue = totalRecs-1000;
    pageNum = totPages;
    gettempMemb();
    }

    public boolean getprev()
    {
    if(index == 0)
    return true;
    else
    return false;
    }

    public boolean getnxt()
    {
    if((index + blockSize) > totalRecs)
    return true;
    else
    return false;
    }

    public void massUpdate()
    {
    update tempMemb;
    }
    }

    Hope this helps.

  • Parul

    Member
    September 20, 2018 at 6:21 pm

    Hi,

    There are few option from which you can choose any one according to your comfirt.

    Hello Madhulika,

    1.  You can enable readOnly attribute value true for the page it will increase Number of query rows from 50000 to 1 million rows and Number of records displayed on VF page will be increased from 1000 to 10000.
    2. You can go for pagination which has to limit.

Log In to reply.

Popular Salesforce Blogs