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
alockremalockrem 

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:column>
    <apex:column>
	<apex:param name="provQuoteId" value="{!q.id}" />
	<apex:dataTable id="tblQlis" value="{!quoteLineItems}" var="qli">
	    <apex:column value="{!qli.id}" />
	</apex:dataTable>
    </apex:column>
</apex:datatable>

 

 

 

    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()
    {
        quoteRecords.clear();
        
        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.

ahab1372ahab1372

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