You need to sign in to do that
Don't have an account?
Ravi K 47
Display parent ,list of child and list of grand child records in visualforce page
Hello All,
I have a requirement to display for each Parent ,list of child records and their list of grand parent records in a visualforce page.
Parent and child have lookup relationship .
But Child to Grand Child are not having any relationship but in GrandChild Object i have one text field "Parent Id " in that filed The Child record id is storing.
Apex Class :
VisuaForce Page :
Due to not having any relationship between Child and GrandChild ,i have created a Wrapper class for that and store thevalues.
From the Apex Class im able to store values of
Parent and List of Child Records into the map ==> IPPIMap and
Child record and list of GrandChild Records ==>PIMcamap
But while referencing in the visualforce page im getting the below error
Unknown property 'ParentchildgrandchildStandardController.IPPIMap'
Could you please check and help me on this request .
I have a requirement to display for each Parent ,list of child records and their list of grand parent records in a visualforce page.
Parent and child have lookup relationship .
But Child to Grand Child are not having any relationship but in GrandChild Object i have one text field "Parent Id " in that filed The Child record id is storing.
Apex Class :
public without sharing class Parentchildgrandchild { public string str; public list<Contact> Pilist; public Map<Contact,list<Grandchild__c>> PIMcamap {get;set;} Map<Account,List<Contact>> IPPIMap {get;set;} public Parentchildgrandchild(ApexPages.StandardController controller) { String pcId = ApexPages.currentPage().getParameters().get('id'); PIMcamap= new Map<Contact,list<Grandchild__c>>(); IPPIMap = new Map<Account,List<Contact>>(); test__c pc= [select id from test__c where id =:pcId]; for(Account Ip:[select id,name,from Account where test__c =:pcId]) { for(Contact pi :[SELECT id,name,parent from Contact where Account =:ip.id order by LastModifiedDate ]) { PIList=new List<Contact>(); list<Grandchild__c> ca= new list<Grandchild__c>(); str=(string)pi.id; ca=[select id, name, parentid from Grandchild__c where parentid=:str]; PIMcamap.put(pi,ca); PIList.add(pi); } IPPIMap.put(ip,PIList); } public class PIwrapper { public Account IP {get;set;} public Contact pi{get;set;} public Grandchild__c mca {get;set;} } }
VisuaForce Page :
<apex:page renderAs="pdf" standardController="MedConnect__Product_Complaint__c" extensions="Parentchildgrandchild"> <apex:repeat value="{!IPPIMap}" var="ac"> <table width = "100%" row ="1" column="3" > <tr><th width = "500">Name #</th></tr> <tr><td >{!ac.Name}</td></tr> <tr><th>Child Name</th></tr> <apex:repeat value="{!IPPIMap[ac]}" var="child"> <tr><td>{!child.name}</td></tr> <tr><th>Grand Child Name</th></tr> <apex:repeat > <tr><td>{!child.name.name}</td></tr> </apex:repeat> </apex:repeat> </table> </apex:repeat> </apex:page>
Due to not having any relationship between Child and GrandChild ,i have created a Wrapper class for that and store thevalues.
From the Apex Class im able to store values of
Parent and List of Child Records into the map ==> IPPIMap and
Child record and list of GrandChild Records ==>PIMcamap
But while referencing in the visualforce page im getting the below error
Unknown property 'ParentchildgrandchildStandardController.IPPIMap'
Could you please check and help me on this request .
Try this
Make this as Public Map<Account,List<Contact>> IPPIMap {get;set;} at line number 7...
Thank You,
Rajesh.
Hello All,
Now i want to display information in PDF format as below for each parent.
Could you please help me on this request.
You can display Grand Child records in a table with all childs or separeted with comas (,)
Thanks
Ravi Kumar k
First you have the page as "RenderAs" = PDF and design the page in the required format.
Let me know if you need more help
Thank You,
Rajesh.