+ Start a Discussion
SunnyShinySunnyShiny 

pageBlockTable > three tables in relation (can i access the third one ?)

<apex:page standardController="Opportunity">

<apex:pageBlock title="LineOrder">
<apex:pageBlockTable value="{! Opportunity.Order__r.LineOrder__r}" var="item">
<apex:column value="{! item.name}"/>
</apex:pageBlockTable>
</apex:pageBlock>

</apex:page>

Is it possible to show LineOrders this way?

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
crop1645crop1645

SunnyShiny

 

Your requirement is not clear to me but in general you can easily do, using VF controller the following

 

Option 1 -- If you want to display a flattened list of a relationship A->B->C, then the controller will need to build such a list by :

 

create a wrapper class FlattenedItem and correspponding variable to List<FlattenedItem>

 

then execute the queries (below) and manipulate the results to instantiate the wrapper class, while building a list of FlattenedItem. You'll need maps to associate query 2 to query 1

 

select id, ..., (select id, ...from b__r) from A and

select id, ..., (select id, ... from c__r) from B

 

 Your VF pageBlockTable will refer to the value of the  list of the FlattenedItem

 

 

Option 2 - If you want to have nested pageblocktables, then your wrapper class needs to be more sophisticated as a wrapper object of A containing a list of wrapper object B where each wrapper B is a list of wrapper C

 

You'll still need the two SOQL queries

 

There are plenty of examples on nested tables and wrapper classes found by web searches 

All Answers

asish1989asish1989
It is not possible because we can go up to two level from parent to child.
SunnyShinySunnyShiny

So, NO solution ?

Or I can create the query through a controller and populate the list ?

 

crop1645crop1645

SunnyShiny

 

Your requirement is not clear to me but in general you can easily do, using VF controller the following

 

Option 1 -- If you want to display a flattened list of a relationship A->B->C, then the controller will need to build such a list by :

 

create a wrapper class FlattenedItem and correspponding variable to List<FlattenedItem>

 

then execute the queries (below) and manipulate the results to instantiate the wrapper class, while building a list of FlattenedItem. You'll need maps to associate query 2 to query 1

 

select id, ..., (select id, ...from b__r) from A and

select id, ..., (select id, ... from c__r) from B

 

 Your VF pageBlockTable will refer to the value of the  list of the FlattenedItem

 

 

Option 2 - If you want to have nested pageblocktables, then your wrapper class needs to be more sophisticated as a wrapper object of A containing a list of wrapper object B where each wrapper B is a list of wrapper C

 

You'll still need the two SOQL queries

 

There are plenty of examples on nested tables and wrapper classes found by web searches 

This was selected as the best answer