0

I have a requirement where I have a table of records of master object. When I click on a row of master table then another table with related child record should get shown.

Parent Object is Supplier And Child Object is Quote

Here is my code,

Visualforce Page

    <apex:pageBlock title="Supplier List" helpTitle="supplier" helpUrl="/apex/testPage" >
        <apex:pageBlockSection showHeader="true" title="List of All Supplier" columns="2" >
            <apex:pageBlockTable var="s" value="{!SupplierReturn}" id="supplier">
            <apex:column headerValue="Supplier Name" value="{!s.name}" ondblclick=""/>
            <apex:param name="sParam" value="{!s.id}" assignTo="{!supplierValue}"/>
            <!--</apex:column>-->
            </apex:pageBlockTable>
            <apex:pageBlockTable var="r" value="{!QuoteReturn}" id="quote">
            <apex:column headerValue="Quote Name" value="{!r.name}" />
            </apex:pageBlockTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

Controller

public with sharing class testPageExt {

public List<Quote__c> quoteList {get;set;}
public List<Supplier__c> supllierList {get;set;}
public String supplierValue {get;set;}

    public testPageExt() {
        quoteList = new List<Quote__c>();
        supllierList = new List<Supplier__c>();
    }
    public List<Quote__c> getQuoteReturn() {
        quoteList = [Select id, name ,RFQ_Supplier__c from Quote__c where RFQ_Supplier__c =:supplierValue ];
         return quoteList;
    }
    public List<Supplier__c> getSupplierReturn() {
        supllierList =[Select id, Name from supplier__c];
        return supllierList;
    }
}
  • I do not see where you are rerendering the quote section or performing any action when a row is clicked. How are you expecting it to redisplay with updated data? – Eric Aug 18 '15 at 11:41
1

Solution for tha same would be like this...

Vf Page

<apex:page Controller="testPageExt" >
<apex:form >
<apex:stylesheet value="/sCSS/25.0/sprites/1342034628000/Theme3/default/gc/versioning.css" />
<apex:stylesheet value="/sCSS/25.0/sprites/1342034628000/Theme3/default/gc/extended.css" />

    <apex:pageBlock title="Supplier List" helpTitle="supplier" helpUrl="/apex/testPage" >
        <apex:pageBlockSection showHeader="true" title="List of All Supplier" columns="2" >
            <apex:pageBlockTable value="{!supllierList }" var="s" id="supplier">
                <apex:column headerValue="Supplier Name" >
                   <apex:commandLink action="{!quoteaction}" value="{!s.name}" reRender="quote">
                    <apex:param name="sParam" value="{!s.id}" assignTo="{!supplierValue}"/>
                    </apex:commandLink>
                </apex:column>     
            </apex:pageBlockTable>
            <apex:pageBlockTable var="r" value="{!quoteList}" id="quote">
                <apex:column headerValue="Quote Name" value="{!r.name}" />
            </apex:pageBlockTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>

Controller

public with sharing class testPageExt {

public List<Quote__c> quoteList {get;set;}
public List<Supplier__c> supllierList {get;set;}
public String supplierValue {get;set;}

    public testPageExt() {
        supllierList =[Select id, Name from supplier__c];
        system.debug('*********'+supllierList );
        quoteList = null;
        getSupllieraction();
    }


    public List<Supplier__c> getSupllieraction() {
        supllierList =[Select id, Name from supplier__c];
        return supllierList ;
    }

    public void quoteaction() {
        quoteList = [Select id, name ,RFQ_Supplier__c from Quote__c where RFQ_Supplier__c =:supplierValue ];
    }
}

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.