0

I'm trying to create a table on Visualforce page like this.

enter image description here

Each pricelookup's description has it's own activity and purchase info.

Custom parent object - Pricing_Lookup__c

Custom child object - Activity_Lookup__c, Purchase_Lookup__c

public class PackageSummaryController {


    public ApexPages.StandardSetController setConPriceLookUp {
    get {
        if(setConPriceLookUp == null) {
            setConPriceLookUp = new ApexPages.StandardSetController(Database.getQueryLocator( [Select Name, Unit_Price__c, Lookup_Name__c, Description__c, (Select Name, Unit_Price__c From Purchase_Lookup__r),(Select Name, Unit_Price__c From Pricing_Item_Lookup__r )   From Pricing_Lookup__c  ]));
        }
        return setConPriceLookUp;
    }
    set;
}


   public List<Pricing_Lookup__c> getRecords() {
    return ( List<Pricing_Lookup__c>) setConPriceLookUp.getRecords();
}

visualforce page.

     <table border = "1" cellpadding = "5" cellspacing = "5">
                <tr>
                    <th>Activities</th>
                    <th>Price</th> 
                </tr>
                <apex:repeat value="{!records}" var="record">
                    <tr>
                    <td>{! record.Name }</td>
                    <td>{! record.Unit_Price__c }</td> 
                    </tr>
                </apex:repeat>

                <tr>
                    <th>Purchases</th>
                    <th>Price</th>
                </tr>
                <apex:repeat value="{!records}" var="record">
                    <tr>
                    <td>{! record.Name }</td>
                    <td>{! record.Unit_Price__c }</td> 
                    </tr>
                </apex:repeat>


             </table>
        </table>

How can I distinguish all three name, unit pricing in visualforce page?

-right now I'm using (record.Name) for pricinglookup's name(mother object)

0

You're actually almost there and you query's fine. Seems like your SOQL query misses the Activity_Lookup__r (if it's not Pricing_Item_Lookup__r) but once you add it, you can use the page markup below.

<!-- iterating over Pricing_Lookup__c list -->
<apex:repeat value="{!records}" var="record">
    {! record.Name }
    <table border = "1" cellpadding = "5" cellspacing = "5">
        <tr>
            <th>Activities</th>
            <th>Price</th> 
        </tr>
        <!-- iterating over related Activity_Lookups__r -->
        <apex:repeat value="{!record.Activity_Lookups__r}" var="activity">
            <tr>
            <td>{! activity.Name }</td>
            <td>{! activity.Unit_Price__c }</td> 
            </tr>
        </apex:repeat>
    </table>

    <table border = "1" cellpadding = "5" cellspacing = "5">
        <tr>
            <th>Purchases</th>
            <th>Price</th>
        </tr>
        <!-- iterating over related Purchase_Lookups__r -->
        <apex:repeat value="{!record.Purchase_Lookups__r}" var="purchase">
            <tr>
            <td>{! purchase.Name }</td>
            <td>{! purchase.Unit_Price__c }</td> 
            </tr>
        </apex:repeat>
    </table>
</apex:repeat>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.