+ Start a Discussion
Deepika Gupta 26Deepika Gupta 26 

Account & Contact Hierarchy

Hi All,
I have a Requirement that i have to show account hierarchy in a VF page and its corresponding contacts in a hierarchy form like Accounts->Account1->Contact1,Contact2
Account2->Contact1,Contact2 like Role hierrachy means in a tree form but not finding exact solution that how can i get tree strcuture in a VF page of Accounts and Contacts.Could any one help me on this?
 
Himanshu Jasuja 9Himanshu Jasuja 9
Hi deepika,
 there is no native way of doing in visualforce. Have to do with external tools. Two ways i know of
 
1. Using Jquery
http://teachmesalesforce.wordpress.com/2012/01/16/displaying-role-hierarchy-on-visualforce-page-tree-view/
2. Using Flex
http://blog.jeffdouglas.com/2008/12/08/flex-salesforcecom-tree-control/
 
Pankaj_GanwaniPankaj_Ganwani
Hi Deepika,

Just explore the below mentioned Jquery to achieve this functionality:

http://ludo.cubicphuse.nl/jquery-treetable/

If you do not want to achieve this through Jquery, then use below mentioned code:
 
<apex:repeat value="{!accounts}" var="obj">
<tr>
<td></td>
<td></td>
</tr>
<apex:repeat value="{!obj.Contacts}" var="objCon">
<tr>
<td>
<div style="padding-left:30px;margin-top:5px;">
{!objCon.Name}
</td>
</tr>
</apex:repeat>
</apex:repeat>

Just modify the code as per your need. You might need to adjust the CSS a little to achieve this desired look.