You need to sign in to do that
Don't have an account?
Curry-Man
4-tier related lists
I have an object that has a series of related lists in a model as follows:
Opportunity>Document>Section>Term
Is there any way in VF to display the Terms as sets of Sections as sets of a Document within a page displaying the Opportunity as the root element?
I think you should check out the "repeat" component. What you can do is define the VF markup for one Term inside one Section inside one Document, and get it looking the way you want (using pageBlocks or however you want it to display). Then add the three levels of nested repeat tags that will get the appropriate objects and display all of them in the proper parent.
For instance, your outermost repeat tags would get all Documents for the given Opportunity and display all of them. Then for each of those, the next level of repeat tags will want to query the Sections for the given document. etc.
Hope that helps.
Michael,
I tried that before posting. VF doesn't seem to allow nesting repeats, data lists, data tables, etc. to avoid soql queries maxing out. I guess this makes sense, since they (SF) can't actually control user input, and if you use nested repeats it is possible to have it set so that Object B is related to Object A, which also has a lookup to Object B. So if you repeated A and for each A found the Bs, it would, if it was a recursive function, create an endless loop.
What I'm thinking of doing is writing a custom controller that would do this, but from a bottom-up method instead of a top-down (fewer queries that way). I'll post as I get further along. Thanks!
apex:repeat does allow nesting data.
<apex:repeat value="{!data}" var="a">
<apex:outputText value="{!a.name}"/>
<apex:repeat value"{!a.data}" var="b">
<apex:outputText value="{b}"/>
</apex:>
</apex>
public List<Data> getData(){
//
return data;
}
public class Data {
public string name {get; set;}
public List<string> data {get; set;}
}
This should work.
Your post worrying about infinite loop seems to assume that SFDC somehow automatically display nested list based on the definition, but michaelforce is not talking about such a convenient function. It's you to specify the nested structure and render the tables by using apex:repeat and nested data structure (of course, you can re-use SObject parent-child relationship for the nested data structure like List<Account>, Account.Contacts. (value="{!accounts}" var="a", value="{!a.contacts}" var="c", value="{!c.name}")
But, for datalist, pageBlockTable, I don't think SFDC "assumes" nested data. The way to control header and style depends on css/javascript/html class name. If you nest pageBlockTable, it will be rendreed, but the class name will be duplicated and headers are not rendered appropriately.
If you use apex:repeat to generate your own list, I don't see any problem (except the amount of your effort...)
ThomasTT
[code]
<apex:page standardController = "Account">
<apex:repeat value="{!Account.Opportunities}" var="opp">
<apex:repeat value="{!opp.OpportunityLineItems}" var="oli">
{!oli.unitprice}
</apex:repeat>
</apex:repeat>
</apex:page>
[/code]
produces
Error: ; nested exception is: common.exception.ApiException: SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object.
The method that I ended up using is as follows:
[code]
[/code]
This allows me to do an apex:repeat on the {!contractpackage} list<string> as many levels as I need to.
Oh, that's true. You can show nested data, but you can't query more than 1 level in 1 SQOL.
I strongly recommend to define Wapper classes (not only for this issue) and use multiple queries to get all required data for the nested data.
If you have to add a checkbox to each opportunity for multiselection, this wrapper will help you so much.
ThomasTT