How to open child records list from custom button on parent object?

How to open child records list from custom button on parent object?

Custom Button:




Visualforce page:


<apex:page controller=”InterestListController”>
    <apex:pageBlock >
        <apex:pageBlockTable value=”{!listInterest}” var=”int”>
            <apex:column value=”{!int.Name}”/>
            <apex:column value=”{!int.Description__c}”/>
        </apex:pageBlockTable>
    </apex:pageBlock>      
</apex:page>

Apex Controller:


public class InterestListController {
    Id memId;
    public List<Interest__c> listInterest {get;set;}
    public InterestListController(){
        listInterest = new List<Interest__c>();
        memId = ApexPages.currentPage().getParameters().get(‘memId’);
        listInterest = [SELECT Name, Description__c FROM Interest__c WHERE Member__c = : memId];
    }
}



Output:


Leave a Reply