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
Chinnu ChinnuChinnu Chinnu 

Can anyone please tell me how to do this VF page

Hey, This is my code..
VF page:
<apex:page controller="ContactsVisualforceController" standardStylesheets="false">
    <apex:form>
    <apex:pageBlock title="Contacts List">
   
             
        <apex:repeat value="{!displayAccounts}" var="acc">
           <dl>
                <dt>Account Name:</dt>
                <dd><apex:outputText value="{!acc.Name}"/></dd> 
            </dl>
            
            <dl><dt>Contact Names:</dt></dl>

            <apex:pageblocktable value="{!acc.Contacts}" var="cont">
                
                <apex:column value="{!cont.firstname}"/>
                <apex:column value="{!cont.lastname}"/>

         </apex:pageblocktable>
       </apex:repeat>
    </apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
public class ContactsVisualforceController {
    public list<Account> displayAccounts {get; set;}
    public ContactsVisualforceController(){
        displayAccounts = [select id,name,(select id,name,firstname,lastname from Contacts) from Account];
    }
}


This is working fine ok.. But now I want to display as Block means

AccountName1 here          All related Contacts For that AccountName1 should display here
AccountName2 here          All related Contacts For that AccountName2 should display here
AccountName3 here          All related Contacts For that AccountName3 should display here

like this I want to display 10 records in one page and another 10 records on another page so pagination we have to use..
So I want how can we do that can anyone please tell me..
Team NubesEliteTeam NubesElite
Hi Chinnu,
Here is the simple example code for pagination according to this code you can make changes in your code
public with sharing class GenericPaginationContrl {
    public List<Sobject> sobjectsLst {get;set;}
    public ApexPages.StandardSetController con {
        get {
            if(con == null) {
                con = new ApexPages.StandardSetController(sobjectsLst);
                con.setPageSize(5);
            }
            return con;
        }
        set;
    }
    public List<Sobject> getRows() {
        return (List<Sobject>)con.getRecords();
    }
}
 
<apex:page controller="PaginationsPageContrl">
    <c:GenericPagination records="{!accLst}" fields="{!accFields}" title="Accounts"/>
    <c:GenericPagination records="{!conLst}" fields="{!conFields}" title="Contacts"/>
    <c:GenericPagination records="{!oppLst}" fields="{!oppFields}" title="Opportunities"/>
</apex:page>



Thank You
www.nubeselite.com

Developement | Training | Consulting

Please Mark this as solution if your problem resolved.
 
Chinnu ChinnuChinnu Chinnu
Yeah ok Thank You I will try it..