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
ppiyushppiyush 

Pagination for Custom List

Hello!

 

I am new to Apex / Visualforce, so will appreciate any help with the following. I have created a custom list using visual force to display all child accounts in a related list. I would like to repeat the same for Contacts of child accounts in the page for parent account.

 

Now, having done that, how do I implement pagination - if the number of contacts / child accounts is significant?

 

See my apex code below:

 

<apex:page standardController="Account" extensions="childAccount">

<style>

.fewerMore { display: none;}

</style>

<apex:form >

 <apex:pageMessages />

 <apex:detail relatedList="true"></apex:detail>

<apex:pageblock id="CustomList" title="Child Accounts"  >

   <apex:pageBlockTable value="{!acctz}" var="o" rendered="{!NOT(ISNULL(acctz))}">

        <apex:column headerValue="Action" >

            <apex:outputLink value="/{!o.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="color:blue; text-decoration:none">Edit</apex:outputLink>

        </apex:column>       

        <apex:column headerValue="Name"> <apex:outputLink value="/{!o.id}">{!o.Name}</apex:outputLink> </apex:column>

        <apex:column value="{!o.Address_Street__c}"/>

        <apex:column value="{!o.Address_City__c}"/>

    <apex:column value="{!o.Office__c}"/>

        <apex:column value="{!o.Type}"/>

   </apex:pageBlockTable>

   <apex:outputLabel value="No records to display" rendered="{!(ISNULL(acctz))}"></apex:outputLabel>

 </apex:pageblock>

 

</apex:form>

</apex:page>

 

 

 

 

public class childAccount {

   

    private List<Account> acctz;

    private Account acct;

 

    public childAccount(ApexPages.StandardController controller) {

        this.acct= (Account)controller.getRecord();

    }

 

    public List<Account> getAcctz()

    {

        Account act = [Select id FROM Account where id = :acct.id];

        acctz = [Select id, Name, Address_Street__c, Address_City__c, Office__c, Type from Account where parentid = :act.id];

    return acctz;

    }

}

 

 

newbiewvfdevnewbiewvfdev
Try using StandardSetController.
guest1231231guest1231231

Cannot you not use Pagination in a StandardController?

sf.dev.ax1103sf.dev.ax1103

HI ppiyush,

     I have similar requirement for pagination for custom related list.Please tell me how you fixed this pagination issue.

 

Thanks