6

So I want to add a nested table for another table. I'm able to add table 2 as nested for table 1. I could do this by adding a pageblocktable table 2 inside the last column of the pageblocktable of table 1(the parent table). Following is my code...

<apex:pageblocksection title="Order Lines" showheader="true" collapsible="true" columns="1">
    <apex:pageBlockTable value="{!gp.ct}" var="p">   //page block 1
        <apex:column></apex:column>
        <apex:column width="40%" >
            <apex:pageblocksection title="Shipment Information" showheader="true" collapsible="true" columns="1">
                <apex:pageBlockTable value="{!gp.ot}" var="q"> //page block 2 inside page block 1 in column
                <apex:column > 
                </apex:column>                 
                </apex:pageBlockTable>  
            </apex:pageblocksection>
        </apex:column> 
    </apex:pageBlockTable>  
</apex:pageblockSection>

Here is the output:

enter image description here

So my question is, can I add the child pageblocktable (table 2) so that it spans across the entire length of each row in the parent table beneath the other columns?

Any suggestion would be helpful.Thanks in advance.

2 Answers 2

12

You need to use breakBefore and colspan parameters of the apex:column:

<apex:pageBlock>
<apex:pageblocksection title="Order Lines" showheader="true" collapsible="true" columns="1">

    <apex:pageBlockTable value="{!accounts}" var="a">
        <apex:column value="{!a.Name}"/>
        <apex:column value="{!a.Street__c}"/>

        <apex:column breakBefore="true" colspan="2">
            <apex:pageblocksection title="Shipment Information" showheader="true" collapsible="true" columns="1">
                <apex:pageBlockTable value="{!a.contacts}" var="c">
                    <apex:column value="{!c.Id}"/>
                    <apex:column value="{!c.Name}"/>
                </apex:pageBlockTable>
            </apex:pageblockSection>
        </apex:column>
    </apex:pageBlockTable>

</apex:pageblockSection>
</apex:pageBlock>

The result:

enter image description here

0
2

If you mean you don't want the second green header bar to appear, I think if you simply remove the second nested pageBlockSection, you'll get what you want.

<apex:pageblocksection title="Order Lines" showheader="true" collapsible="true" columns="1">
 <apex:pageBlockTable value="{!gp.ct}" var="p">   //page block 1
    <apex:column></apex:column>
    <apex:column width="40%" >
            <apex:pageBlockTable value="{!gp.ot}" var="q"> //page block 2 inside page block 1 in column
            <apex:column > 
            </apex:column>                 
            </apex:pageBlockTable>  
    </apex:column> 
 </apex:pageBlockTable>  
</apex:pageblockSection>
3
  • No I need the green header. I just want the child table should come right below the parent table. Is it possible?
    – MnZ
    Sep 16, 2014 at 14:08
  • ok. now I understand.
    – pchittum
    Sep 16, 2014 at 15:55
  • Hi peter. You can see my code. I don't want to add a new pageblocktable in another column of another pageblocktable. @mast0r has already posted what I desired. A child table below a parent table. Thanks for helping. :)
    – MnZ
    Sep 16, 2014 at 16:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .