+ Start a Discussion
GerhardNewman2GerhardNewman2 

Inner datatable or pageblocktable

I want to have a related list on my accounts page that shows open opportunites.
For each open opportunity I want to list any products
I can't find anyway of outputing any information at all after each row in my PageBlockTable.
In the code below the text "OutputAnythingHere" does not get rendered.
What I want to do is add a new pageBlockTable at my OutputAnythingHere placeholder, which would give me an inner table to iterate the products for the opportunity.
 
Code:
<apex:form >
<apex:pageBlock title="Open Opportunites">
    <apex:pageBlockButtons location="top">
        <apex:commandButton action="/006/e—retURL=/{!id}" value="New Opportunity" id="theButton"/>
    </apex:pageBlockButtons>
    <apex:pageblocktable value="{!OpenOpportunities}" var="aOpportunity" width="100%" >
                <apex:column width="3%" headervalue="Action">
                    <apex:outputLink value="/{!aOpportunity.ID}/e"><b>Edit</b>
                         <apex:param name="retURL" value="/{!id}"/>
                    </apex:outputLink>
                </apex:column>
                <apex:column width="35%" headervalue="Opportunity Name">
                    <apex:outputLink value="/{!aOpportunity.ID}">{!aOpportunity.Name}</apex:outputLink>
                </apex:column>
                <apex:column width="25%" headervalue="Stage" value="{!aOpportunity.Stagename}"/>
                <apex:column width="10%" headerdir="RTL" headervalue="Net Revenue" dir="RTL" value="{!aOpportunity.CurrencyIsoCode} {!aOpportunity.Sum_Net_Revenue__c}"/>  
                <table width="100%"><tr align="right"><td><b>OutputAnythingHere</b></td></tr></table>
    </apex:pageblockTable> 
    <table width="100%"><tr align="right"><td><b>Total {!OpenTotal}</b></td></tr></table>
    </apex:pageBlock> 
</apex:form>

Thanks,
Gerhard
Scott.MScott.M
Hi,

Couldn't you use the <apex:repeat> tag to iterate through the products something like:

Code:
<apex:repeat value="{!products}" var="product">
  <tr>
    <td>{!product.Name}</td>
  </tr>
</apex:repeat>

 


GerhardNewman2GerhardNewman2

The problem isn't a loop, its an inner loop.

Using a repeat like this:

Code:
        <apex:repeat value="{!strings}" var="string">
            <apex:outputText value="{!string}" id="theValue"/><br/>
        </apex:repeat>

works fine by itself, but placing this code inside a PageBlockTable does absolutely nothing.

As said in my original post, I cannot get anything additional rendered inside the PageBlockTable loop.

 

GerhardNewman2GerhardNewman2
I have discovered that repeat loops do work with inner repeat loops like this:
Code:
        <apex:repeat value="{!LostOpportunities}" var="tstring">
            <apex:outputtext value="{!tstring.name}" id="theValue"/><br/>
            <apex:repeat value="{!strings}" var="string">
                <apex:outputText value="{!string}" id="theValue"/><br/>
            </apex:repeat>
        </apex:repeat>

This gives me a partial solution as I can now at least output the data. However I would much prefer to be able to use  PageBlockTable so that I get correct styling.  Now I will have to start the formating process all over again.....
jwetzlerjwetzler
pageBlockTable and dataTable are basically the same component, except the pageBlockTable has a little salesforce styling/label magic.  repeat, however, is different from the two of those.

By name, pageBlockTable and dataTable create <table> tags and <tr> and <td> tags.  Repeat works for iteration the same way pBT does but does not output these table tags for you.  I think you are going to have a hard time getting what you want by nesting pBTs, because you're going to wind up with nested <table>s.  While it is legal HTML, I can't promise that our css is going to behave the way you'd expect it to.  pageBlockTable's styling is very specific to our use cases, which have not included nesting lists.
sparkysparky
Gerhard, I'm wondering if you ever got this to work.  And if so, what method you used.  I need to do something similar.

Thanks!
jwetzlerjwetzler
We had an internal developer get nested dataTables to work by nesting them inside of columns.

So something like:
Code:
<apex:dataTable>
 <apex:column>
  <apex:dataTable>
   <apex:column/>
   <apex:column/>
  </apex:dataTable>
 </apex:column>
</apex:dataTable>


 Seems like it should work.

GerhardNewman2GerhardNewman2

I used apex:repeat as the solution.  The code below works fine for me and it looks just how I wanted.

Code:
<apex:pageBlock title="Lost Opportunites">
    <table width="100%" class="list">
    <thead>
        <tr class='headerRow'><th class='headerRow' scope="col" WIDTH="3%">Action</th><th class='headerRow' scope="col" WIDTH="25%">Opportunity Name</th><th class='headerRow' scope="col" WIDTH="25%">Stage</th><th class='headerRow' WIDTH="20%">Product</th><th class="headerRow"scope="col" align="right" width="8%">Net Line Item</th><th class='headerRow' scope="col" ALIGN="RIGHT" WIDTH="10%">Net Revenue</th></tr>
    </thead>
    <apex:repeat value="{!LostOpportunities}" var="aOpportunity">
        <tbody><tr>
            <td><apex:outputLink value="/{!aOpportunity.ID}/e"><b>Edit</b>
                <apex:param name="retURL" value="/{!id}"/>
            </apex:outputLink></td>
            <td colspan="1"><apex:outputLink value="/{!aOpportunity.ID}">{!aOpportunity.Name}</apex:outputLink></td>
            <td colspan="3"><apex:outputText value="{!aOpportunity.StageName}"/></td>
            <td align="right">{!aOpportunity.CurrencyIsoCode} {!aOpportunity.Sum_Net_Revenue__c}</td>
        </tr>       
        <apex:repeat value="{!aOpportunity.opportunityLineItems}" var="aLineItem" rendered="{!showProducts}">
            <tr><td></td><td></td><td></td><td>{!aLineItem.PriceBookEntry.Name}</td><td align="right">{!aLineItem.revenue_to__c}</td></tr>    
        </apex:repeat>
        </tbody>
    </apex:repeat>
    </table>
    <table width="100%" class="list"><tr align="right"><td><b>Total {!LostTotal}</b></td></tr></table> 
</apex:pageBlock>