+ Start a Discussion

DataTable inside another DataTable

I am trying to embed a DataTable inside of a DataTable.  Please help me understand what I'm doing wrong.


Note: I have never gotten this to work, so my approach may be completely off.



<apex:datatable id="tblQuotes" value="{!quotes}" var="q">
    <apex:column >
	<apex:outputText value="{!q.name}" />
	<apex:param name="provQuoteId" value="{!q.id}" />
	<apex:dataTable id="tblQlis" value="{!quoteLineItems}" var="qli">
	    <apex:column value="{!qli.id}" />




    public class quoteRecord
        public String id {get;set;}
        public String name {get;set;}
        public Boolean selected {get;set;}
        public quoteRecord(
            String setId,
            String setName,
            Boolean setSelected)
            id = setId;
            name = setName;
            selected = setSelected;

    public List<quoteRecord> getQuotes()
        for (quote q : [SELECT id, name
                        FROM quote
                        WHERE opportunityId = : opportunityId])
            quoteRecords.add(new quoteRecord(q.id, q.name, false));
        return quoteRecords;

    public List<quoteLineItem> getQuoteLineItems()
        return [SELECT id, quote.name, pricebookentry.product2.name, provisioning_page__c
                FROM quoteLineItem
                WHERE quoteId = : ApexPages.currentPage().getParameters().get('provQuoteId')];



Thank you for any help.


your controller is executed only once, so it can query the line items only once. Passing the quote ID repeatedly (once for every iteration of the outer datatable) and then querying the line items each time is not going to work.


Instead, query the quote along with the line items (search the docu for subqueries). Then in the inner datatable, set the value to q.quoteLineItems


Not sure if nested datatables are supported, please let us know