function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Janno RipJanno Rip 

Display Inner Joing in PageBlockTable

Hello there,

I have a bit of trouble correctly displaying my data:

my apex class:
 
public class QuoteList {

public Opportunity currentOpp {get;set;}
public List<Quote> quotes  {get;set;} 

 public QuoteList(ApexPages.StandardController stdController) {
     currentOpp  = [SELECT Id FROM Opportunity WHERE ID =: stdController.getID()];
     }
    
public PageReference getPdfs() {         

quotes = [SELECT Id,Name,(SELECT Id,CreatedDate,Name,ContentVersionDocumentId,QuoteId FROM QuoteDocuments)FROM Quote WHERE OpportunityId = :currentOpp.id];


return null;
}
}

my visualforce page:
 
<apex:page standardcontroller="Opportunity" extensions="QuoteList" lightningStylesheets="true" action="{!getPdfs}">  
       
    
  <apex:form >
<apex:pageBlock >  
    <apex:repeat value="{!quotes}" var="quote">
    
      <apex:pageBlockTable value="{!quote.QuoteDocuments}" var="pdf" >

        <apex:column headerValue="Name">
        <apex:outputlink value="https://meinestadt--syncs.my.salesforce.com/servlet/servlet.FileDownload?file={!pdf.id}" target="_blank">{!pdf.Name}</apex:outputlink>
       </apex:column>
       
        <apex:column value="{!pdf.CreatedDate}"/>
       
     </apex:pageBlockTable>
  
    </apex:repeat>

 </apex:pageBlock>
 </apex:form>
</apex:page>

the result:

User-added image
I am doing almost identical code (class & vf) when I display all contacts from the account related to a task - this works just fine:

User-added image
Where did I go wrong?

Thanks!
Footprints on the MoonFootprints on the Moon
Hey Janno,
You have put <apex:column headerValue="Name"> inside  <apex:pageBlockTable> which is inside <apex:repeat>
This is basically loop inside loop.
Try moving both <apex:column headerValue="Name"> and <apex:column value="{!pdf.CreatedDate}"/> out of <apex:pageBlockTable>.

Hope this helps!
Janno RipJanno Rip
Hello Footprints on the Moon,

first of all: Love your Name ;)

Regarding your advice I stumbled:

 <apex:column> must be the direct child of either <apex:dataTable> or <apex:pageBlockTable>

So what other "type" of table can I use here? And for reference. Here is my code for the task - contact - list:
 
<apex:page standardcontroller="Task" extensions="TaskList" lightningStylesheets="true" action="{!getContacts}">  

<apex:pageBlock >
  <apex:form >
  
   <apex:repeat value="{!acc}" var="account"> 
      
      <apex:pageBlockTable value="{!account.Contacts}" var="con">
       
          <apex:column value="{!con.salutation}"/>
          
          <apex:column headerValue="Name">
          <apex:outputlink value="/{!con.id}" target="_blank">{!con.name}</apex:outputlink>
          </apex:column>
                   
          <apex:column headerValue="Phone">
                   <apex:outputlink value="tel:{!con.phone}">{!con.phone}</apex:outputlink>
                </apex:column>
                
           <apex:column value="{!con.email}"/>
         
          </apex:pageBlockTable>
           
    </apex:repeat> 
       
  </apex:form>
 </apex:pageBlock>
</apex:page>
and the result:

User-added image
Footprints on the MoonFootprints on the Moon
Hey Janno,
To avoid the repeating of column header,
here's very raw fix, just to have columns once and then regular data from account's contacts-
 
<apex:pageBlock >
        <apex:form >
             <table width="100%">
            <tr>
                <th>Salutation</th>
                <th>Name</th>
                <th>Phone</th> 
                <th>Email</th> 
            </tr> 
            <apex:dataTable value="{!acc}" var="account">
                <apex:repeat value="{!account.Contacts}" var="con">
                    <apex:column >
                        {!con.salutation}                                            
                    </apex:column>
                    
                    <apex:column >
                        <apex:outputlink value="/{!con.id}" target="_blank">{!con.name}</apex:outputlink>
                    </apex:column>
                    
                    <apex:column >
                        <apex:outputlink value="tel:{!con.phone}">{!con.phone}</apex:outputlink>
                    </apex:column>
                    
                    <apex:column value="{!con.email}"></apex:column>
                    
                </apex:repeat>
            </apex:dataTable>
               </table>  
            <!--</apex:repeat>-->
        </apex:form>
    </apex:pageBlock>
Setting column headers only once at the beginning of dataTable using basic HTML table tags.
Let me know if this helps!
 
Janno RipJanno Rip
Hey,

unfortunetaly this is what it will look like:

User-added image