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
t.deepthi05t.deepthi05 

displaying the records in same page on click of next

Hi All,

I want to display all the records in single page 

i.e intial when the  Page  load five records have to display and when i click on next button it has load next 5 records with the inital 5 records 
i.e. a total of 10 records 

Can i have any work around for the above requirement.

Using custom controller or javascript

bob_buzzardbob_buzzard

You can do this with a custom controller and a command button.  If you have an idea of the maximum that you will display, you can simply retrieve them all in the constructor and show them to the user.  If there are likely to be a lot of records that may cause a problem in the view state, in which case you'd be better to retrieve them as part of a getter when the user clicks the button, especially if you aren't allowing the user to make any changes.  Here's an example - thre might be the odd typo but hopefully you get the idea:

Controller:
 

public class MyController
{
    public transient List<Account> accs {get; set;}
    public Integer size {get; set;}

    public MyController()
    {
         size=5;
         setupAccounts();
    }

    private void setupAccounts()
    {
       accounts=[select id, Name from Account limit :size];
    }

   public void next()
   {
      size+=5;
      setupRecords();
   }
}

Page:
 

<apex:page controller="MyController">
 <apex:form>
  <apex:pageBlock title="Accounts">
    <apex:pageBlockButtons>
      <apex:commandButton action="{!next}" />
    </apex:pageBlockButtons>
    <apex:pageBlockTable value="{!accounts}" var="acc">
      <apex:column value="{!acc.id}"/>
      <apex:column value="{!acc.Name}"/>
    </apex:pageBlockTable>
  </apex:pageBlock>
 </apex:form>
</apex:page>



 

t.deepthi05t.deepthi05
Thanks Bob it worked for me.
can i have the same functionality using javascript
t.deepthi05t.deepthi05
Is there way to display the records without querying again using standard set controller