I have a pageblocktable in Vf page where accounts records are rendered. I have Zip code as Child object for Account object .

Now I want to show the relatedlist in that Vf page where the related list are shown

What is the best layout and wayout to do this.??

  • Note--The relatedlist that I want to show is in pageblocktable..
    – Arun SFDC
    Jan 29, 2013 at 9:55

2 Answers 2



List<Account> acc { get; set; }

public YourClass()
    acc = [ Select Id, Name, (Select Id, Name From ZipCodes__r) From Account ];


<apex:pageBlockTable value="{!acc}" var="a">
    <apex:column value="{!a.id}"/>
    <apex:column value="{!a.name}"/>
    <apex:column breakBefore="true" colspan="2" style="background:#eee;">
        <b>Related ZIP codes: </b>
        <apex:repeat value="{!a.ZipCodes__r}" var="z">

We can't tell you what layout is the best ;) One option would be to have 2 columns and use the standard tag for the related list:

<apex:pageBlockTable value="{!accounts}" var="a">
    <apex:column value="{!a.Name}" />
    <apex:column headerValue="ZIP Codes">
        <apex:relatedList subject="{!a.Id}" list="ZIP_Codes__r" />

You can style it a bit, for example to remove the header images from the list use the title attribute... Or if you want - embed another pageblocktable, repeat tag etc and have full control over the styling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.