You need to sign in to do that
Don't have an account?
Dynamically render table based on list size VF Page as PDF
Hello,
I have a vf page as PDF which pulls all of the "Additional Owners" from a Lead, and places them in a table. Right now I use the class to determine the list size like this:
Thank you!
-Ryan
VF Page table section:
I have a vf page as PDF which pulls all of the "Additional Owners" from a Lead, and places them in a table. Right now I use the class to determine the list size like this:
public Integer add {get;set;} public LeadPDF(){ AO = [SELECT Id,Name FROM Additional_Owner__c WHERE Lead__c =: Ld[0].Id]; add = AO.size();So then my VF Page renders the section if the size equals 1, 2, 3 and so on. Is there a better way to write this VF Page to loop and add additional spaces if needed? I could potentially have 30+ additional owners at some point and really don't want to write 30+ different tables.
Thank you!
-Ryan
VF Page table section:
<apex:outputPanel rendered="{!IF(add=1,True,False)}"> <center><b>Additional Owner</b></center> <table style="width:100%"> <tr> <th>Entity/Officer</th> <th>Ownership Type</th> <th>Officer Email</th> <th>Phone</th> <th>Ownership Percentage</th> </tr> <tr> <td><apex:outputLabel style="color:black"><apex:outputfield value="{!AO[0].Entity_Officer__c}"/></apex:outputLabel></td> <td>{!AO[0].Ownership_Type__c}</td> <td>{!AO[0].Officer_Email__c}</td> <td>{!AO[0].Phone__c}</td> <td>{!AO[0].Ownership_Percentage__c}</td> </tr> </table> </apex:outputPanel> <apex:outputPanel rendered="{!IF(add=2,True,False)}"><center><b>Additional Owners</b></center> <table style="width:100%"> <tr> <th>Entity/Officer</th> <th>Ownership Type</th> <th>Officer Email</th> <th>Phone</th> <th>Ownership Percentage</th> </tr> <tr> <td><apex:outputLabel style="color:black;"><apex:outputfield value="{!AO[0].Entity_Officer__c}"/></apex:outputLabel></td> <td>{!AO[0].Ownership_Type__c}</td> <td>{!AO[0].Officer_Email__c}</td> <td>{!AO[0].Phone__c}</td> <td>{!AO[0].Ownership_Percentage__c}</td> </tr> <tr> <td><apex:outputfield value="{!AO[1].Entity_Officer__c}"/></td> <td>{!AO[1].Ownership_Type__c}</td> <td>{!AO[1].Officer_Email__c}</td> <td>{!AO[1].Phone__c}</td> <td>{!AO[1].Ownership_Percentage__c}</td> </tr> </table> </apex:outputPanel> <apex:outputPanel rendered="{!IF(add=3,True,False)}">EXTRA TABLE SECTIONS HERE</apex:outputPanel> <apex:outputPanel rendered="{!IF(add=4,True,False)}">EXTRA TABLE SECTIONS HERE</apex:outputPanel> <apex:outputPanel rendered="{!IF(add=5,True,False)}">EXTRA TABLE SECTIONS HERE</apex:outputPanel>
All Answers
Now I have just one table as follows, and updated the IF so if there is at least one Additional Owner then it will display and continue the loop through all the rest.