• RV328
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
I am trying to print Account Name and related cotact name in the other columns of pageblocktable

<apex:page standardController="Account" extensions="CustAccContExtn" >
    <apex:form >
        <apex:pageBlock title="A/c and Cont in Table" >
            <apex:pageblockButtons location="bottom">
                <apex:commandButton value="Fetch Account" action="{!getAccountsResc}"/>
            </apex:pageblockButtons>
            <apex:pageBlockSection >
                <apex:pageBlockTable value="{!allAccs}" var="ac">
                    <apex:column value="{!ac.Name}" headerValue="Account Name"/>
                    
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

public class CustAccContExtn {
    
    public List<Account> allAccs {get;set;}
    
    public PageReference getAccountsResc() {
        allAccs = [SELECT id, Name FROM Account];
        return null;
    }
    public CustAccContExtn(ApexPages.StandardController controller) {
        allAccs =  new List<Account>();
    }
}


What update do I need to make on select statement to pull the name of all contact associated for an account and how do i call them in apex:column

Please Help!

 
  • March 29, 2015
  • Like
  • 0
Here is the code:

<apex:page standardController="Account">
    <apex:pageBlock title="{! $User.FirstName} {! $User.LastName}">
        You are viewinf account of {! account.name}
    </apex:pageBlock>
    
    <apex:pageBlock title="Contacts">
        <apex:form>
            <apex:dataTable value=" {! account.Contacts}" var="AC" cellpadding="4" border="1">
                <apex:column>
                    <apex:facet name="header"> Name </apex:facet>
                        <apex:commandLink reRender="detail">
                        {! AC.Name}
                        <apex:param name="cid" value="{! AC.id}"/>
                        </apex:commandLink>
                </apex:column>
                <apex:column>
                    <apex:facet name="header"> Phone </apex:facet>
                    {! AC.Phone}
                </apex:column>
            </apex:dataTable>
        </apex:form>
    </apex:pageBlock>
    <apex:outputPanel id="detail">
        <apex:detail subject="{! $CurrentPage.parameters.cid}" inlineEdit="false" relatedList="false" title="false"/>
    </apex:outputPanel>
</apex:page>
  • March 18, 2015
  • Like
  • 0