+ Start a Discussion
J CesarJ Cesar 

How to display multiple nested lists on a Visualforce page?

I need to display a list of child objects related to a master record, each with a list of child objects, and some fields across both levels need to be available for inline editing.
The structure is as follows:
  • Master record (only passes the ID as reference to the controller for SOQL query)
  • List of child objects Child__c with a lookup to Master__c, each with a 
  • List of child objects of Child__c, Grandchild__c, with a lookup to Child__c
I have no experience with nested lists in VF, any advice how to go about this one would be greatly appreciated.
 
I was thinking of a wrapper class, but how would I go about implementing nested lists in a wrapper class as they need to be ordered?
The query on the controller side pulls out the following:
SELECT Id, Name, Master__c, Quantity__c, Price__c, (SELECT Id, Name, Quantity__c FROM Grandchildren__r) FROM Child__c WHERE Master__c = :MasterId

Save button would update both lists...
Khan AnasKhan Anas (Salesforce Developers) 
Hi Jernej,

I trust you are doing very well.

Please refer to the below blogs which has sample code which might help you with the above issue. Kindly try to implement according to your requirement.

http://www.forcetree.com/2011/04/tree-view-in-visualforce-page.html

http://forceschool.blogspot.com/2011/06/show-hierarchy-in-visualforce-page.html

http://salesforceblogger.blogspot.com/2012/03/hierarchy-in-visualforce.html


I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.

Thanks and Regards,
Khan Anas