Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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.??

share|improve this question
    
Note--The relatedlist that I want to show is in pageblocktable.. –  Arun SFDC Jan 29 '13 at 9:55
add comment

2 Answers

Class:

List<Account> acc { get; set; }

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

Page:

<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">
            {!z.Name}, 
        </apex:repeat>
    </apex:column>
</apex:pageBlockTable>
share|improve this answer
add comment

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" />
    </apex:column>
</apex:pageBlockTable>

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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