function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ArmanMArmanM 

Visualforce PDF page getting information from child object

Hi, 

I have created a controller that would query some information from a custom child object so I can use it from its parent object. These two objects have a master-detail relationship.  

Parent/master object: Media_Plan__c
Child/detailed object: Media_Deliverable__c

I need to have a visualforce page that renders as PDF in Media_Plan__c layout. This page would get triggered with a button on the layout, this pdf page would get some information from Media_Plan__c and from its child object Media_Deliverable__c. I need some help with this page, how can I apply my controller to achieve this? I was thinking of using apex:repeat, but not sure how to apply this.   

The following is my controller -
 
public with sharing class Abc {
    public List<Media_Deliverable__c > childLs{get;set;}
    
    public Abc(ApexPages.StandardController controller) {
        
      	childLs= new List<Media_Deliverable__c >();
        id parId = ApexPages.currentPage().getParameters().get('id');

      	childLs = [select id, Deliverable_Name__c, Product__c, Product_copy__c, 
		Quantity__c, Rate__c, True_Total_Value__c, Value__c, Value_Add__c,
		Value_add_price__c from Media_Deliverable__c where Media_Plan__c = :parId ];
    }
}
Best Answer chosen by ArmanM
Flint LockwoodFlint Lockwood
Use <apex:datatable> which essentially function the same as the repeater

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_dataTable.htm
 
<apex:dataTable value="{!childls}" var="c">
<apex:column value="{!c.Deliverable_Name__c}"/> <!--repeat for applicable fields-->
</apex:dataTable>