Find your content:

Search form

You are here

Filtering related list on custom object VF page (with custom controller)

 
Share

I have a VF page related to a custom object called Equipment__c (named 'obj' in the page) as shown in the snippet below:

<apex:page controller="Reserve_Equipment" tabStyle="Equipment__c" action="{!Init}">
  <apex:relatedList subject="{!obj}" list="Equipment_Reservations__r" title="Existing Equipment Reservations" />   
  <apex:form id="form">
  <apex:actionFunction action="{!DisableLookUp}" name="DisableLookUp" reRender="form"/>
    <apex:pageBlock >
    <apex:pageBlockSection title="Reserve Equipment" columns="1">
    <apex:outputField value="{!obj.Name}"/>
    <apex:outputField value="{!obj.Equipment_Tag__c}"/>
     </apex:pageBlockSection>
...

It works fine in that it shows the Equipment_Reservations_c related list for my Equipment_c object.

But now I want to limit the records shown in this instance of the related list. On this page I only want to show records related to this equipment where Equipment_Reservations__c.Active = true and Equipment_Reservations__c.Start_Date__c >= system.today().

Since the 'subject' of my related list is actually my Equipment__c object I am not sure how I would do this.

Any help you could provide would be appreciated.


Attribution to: AngiB

Possible Suggestion/Solution #1

You wouldn't be able to leverage the rendered attribute when using the apex:relatedList, you would have to render your own related list using apex:repeat or apex:dataTable, and you can then use the rendered attribute to only selectively render rows, based on the boolean condition.


Attribution to: techtrekker
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4661

My Block Status

My Block Content