+ Start a Discussion
nagalakshminagalakshmi 

displaying accounts and contacts at a time in same visual force page

Hi,

 

I want to display the account records and related contacts for each account record in a visual force page.

I am reach the requirement through command links that is iam displayed the accounts in visual force page and if we click on any account that will display the related contacts. but now i want to display each account record and related contacts line by line with line seperation for every account and contact record group. please any one help me how to solve these

LakshmanLakshman

Does it means a output will be something like below?

 

Account 1 Title

First Name  LastName Phone Email
xxx                   xxx               xxx        xxx

 

Account 2 Title

First Name  LastName Phone Email
xxx                   xxx               xxx        xxx

I think you can create a visualforce component which will display list of contacts.

Hope this is pretty simple jon using standard functionality.

And in your list page loop through accounts and call visualforce component.

Let me give a try for this.

raju.Braju.B

Hi laxman,

 

I too need same requirement,But the page should be like below

 

Account 1 title

 

Contact1

Contact2

.

.

.

 

Account 2 title

Contact1

Contact2

Contact3

.

.

.

like this...

So please can you help me out.....???

 

 

Thanks & Regards

 

Raju.B

nagalakshminagalakshmi

Hi,

 

i want the requirement like which has posted by raju.

 

 

 

 

thanks,

Lakshmi.

LakshmanLakshman

Sure Raju will post code later today.

sravusravu

try the following code:

 

Apex Class :

 

 

public class AccountContactList {
    public List<Account> getList(){
        return [Select Name, Id, (Select Name From Contacts) From Account];
    }
}

 

 

Visualforce Page:

 

 

<apex:page controller="AccountContactList">
    <apex:form >
         <apex:repeat value="{!List}" var="a">
           <table>
            <tr>
               <td style="font-weight:bold;">
                 <apex:outputText >{!a.name}</apex:outputText>           
               </td>
            </tr>
            <tr>
              <td>
                <apex:repeat value="{!a.Contacts}" var="c">
                  <apex:outputText >{!c.Name}</apex:outputText><br/>
                </apex:repeat>
              </td>
           </tr>
           </table>
        </apex:repeat>
    </apex:form>
</apex:page>

 

 

 

 

b-liub-liu

What if you expanded this to add more contact info details? I am trying to make a contact table in my visualforce page or somehow embed the contacts tab in the page..

 

Thank you