Creating VF without Apex code - #1 in a series

posted Jul 9, 2014, 11:50 AM by Ezra Kenigsberg   [ updated Oct 16, 2014, 7:30 PM ]
I love that Visualforce has a Related List tag that makes it easy to plop a related list into a Visualforce page--without Apex code.

I HATE HATE HATE that it's not very flexible (eg, there's no way to customize the columns shown).

I installed PageBlockTableEnhancerADV, added the ideas from Item #3 in "Making Related List without using Apex Class"and expanded on them a little to make a homebrew related list without Apex controller code. It's below. woohoo!

homebrew related list

<pbe:PageBlockTableEnhancerADV enableExport="false" targetPbTableIds="Implementation_Contact_Roles__r" paginate="true" defaultPageSize="5" pageSizeOptions="5,10,20,30,40,50,100" />
<apex:pageBlock title="Implementation Contact Roles"> 
<center><apex:commandButton action="{!URLFOR($Action.Implementation_Contact_Role__c.New, null, [CF00N500000030Bcw=Opportunity.Name])}" value="Add" id="newICR"/></center>
<apex:pageBlockSection columns="1">
<apex:pageBlockTable value="{!Opportunity.Implementation_Contact_Roles__r}" var="child" id="Implementation_Contact_Roles__r">
   <apex:column headerValue="Action">
   <apex:outputLink value="{!URLFOR($Action.Implementation_Contact_Role__c.Edit, child.id)}" id="editLink" styleClass="actionLink"><font color="blue">Edit</font></apex:outputLink> | 
   <apex:outputLink value="{!URLFOR($Action.Implementation_Contact_Role__c.Delete, child.id, [retURL='/apex/CRF?id=' + id], true)}" onclick="return window.confirm('Are you sure?');" styleClass="actionLink"><font color="blue"> Del</font></apex:outputLink>
   </apex:column>
   <apex:column headervalue="Full Name">
   <apex:outputLink value="/{!child.Id}">{!child.Contact__r.FirstName} {!child.Contact__r.LastName}</apex:outputLink>
   </apex:column>
   <apex:column headerValue="Project Role" value="{!child.Project_Role__c}"/>
   <apex:column headerValue="Email" value="{!child.Contact__r.Email}"/>
   <apex:column headerValue="Notes" value="{!child.Notes__c}"/>
</apex:pageBlockTable> 
</apex:pageBlockSection>
</apex:pageBlock> 
Comments