Wednesday 29 August 2012

Related List on Custom VFP

Hi Friends ,

In this Post you will found how we can show related list on  Custom Visual force Page.

Consider : I have a account record. This account record have many child record on Contact object.
Contact Object have look up of Account.

There is apex code :-

public class CusttomAccount
{
    public Account acc {set;get;}
    public CusttomAccount()
    {
        acc = new Account();
        acc = [select id ,name from Account limit 1];
    }  

}

There is Visual force Page code :- 


<apex:page controller="CusttomAccount" showChat="false" sidebar="false">  
    <apex:pageblock   >
        <apex:pageBlockSection title="Record Detail">
            <apex:pageBlockSectionItem>
             <apex:outputLabel value="Name" />
                <apex:outputLabel value="{!acc.name}" />
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageblock>
    <apex:relatedList subject="{!acc.id}"  list="Contacts" />
    <!-- in list attribute we fill the relationship name and subject we pass the account id whose related list will show -->
    <!--  if your want you show enhancelist please uncomment this code  -->
    <!-- <apex:enhancedList  type="contact" height="300" customizable="false" rowsPerPage="10"  /> -->
</apex:page>



No comments:

Post a Comment