Friday, March 23, 2012

Related List without using Apex Class

1) Using <apex:relatedlist>
Suppose you have standard Case object and have one custom child object named "Child__c" to case. Then you can show your relatedlist on vf page using below code.
<apex:page standardController="Case"> 
<apex:relatedList list="Childs__r"/> 
</apex:page>
 
2) Using relations objects iteration and Standard Tags. 
<apex:page standardController="Case"> 
<apex:sectionHeader title="http://www.aslambari.com" subtitle="Related List Example"/> 
<apex:pageBlock> 
<apex:pageBlockTable value="{!Case.Childs__r}" var="child"> 
<apex:column headervalue="Name"><apex:outputLink value="/{!child.id}">{!child.name}</apex:outputLink>
</apex:column> 
<apex:column value="{!child.detail__c}"/> 
<apex:column value="{!child.is_active__c}"/> 
<apex:column value="{!child.createddate}"/> 
<apex:column value="{!child.createdbyId}"/> 
</apex:pageBlockTable>  </apex:pageBlock> 
</apex:page> 

No comments:

Post a Comment