+ Start a Discussion
Chinnu ChinnuChinnu Chinnu 

Develop a vf page and display the account with corresponding related contacts

Rounak SharmaRounak Sharma
hello chinnu,
Please check the below url 
https://trailhead.salesforce.com/en/content/learn/modules/visualforce_fundamentals/visualforce_output_components
I am sure it will help you.
Please let me know if still you have any doubt
thanks
Khan AnasKhan Anas (Salesforce Developers) 
Hi Chinnu,

Greetings to you!

Please refer to the below links which might help you further with the above requirement.

https://www.biswajeetsamal.com/blog/salesforce-how-to-craete-treeview-in-visualforce-page/

http://salesforceblogger.blogspot.com/2012/03/hierarchy-in-visualforce.html

http://www.forcetree.com/2011/04/tree-view-in-visualforce-page.html

http://www.infallibletechie.com/2012/11/tree-view-in-visualforce-page.html

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Chinnu ChinnuChinnu Chinnu
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..
Rounak SharmaRounak Sharma
Hello chinnu,

Please refer the below url for it
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_sosc_pagination.htm
https://trailhead.salesforce.com/en/content/learn/modules/visualforce_fundamentals/visualforce_standard_list_controllers

Please let me know if it helps.
Thanks
Chinnu ChinnuChinnu Chinnu
Hi Rounak,
Here I'm using custom controller in Vf page so for that I want...
Rounak SharmaRounak Sharma
Hello,
i don't think you can do pagination without using standardList controller. Go through the trailhead and it will be more clear to you. 

Thanks