You need to sign in to do that
Don't have an account?
shan jakkula
related contacts in pageblocktable for selected account
Hi,
I'm new salesforce and i have Requirement like...
I have all Account Names in Dropdown(using Apex:selectList i have done this), if select any of the Account Name from the Dropdown and after clicking on commandButton ,i need to Display all related contacts for the particular Account in pageBlockTable.Do i need to write inner Class for this? if yes please give me some sample code to achieve this.
Thanks in Advance
shan
I'm new salesforce and i have Requirement like...
I have all Account Names in Dropdown(using Apex:selectList i have done this), if select any of the Account Name from the Dropdown and after clicking on commandButton ,i need to Display all related contacts for the particular Account in pageBlockTable.Do i need to write inner Class for this? if yes please give me some sample code to achieve this.
Thanks in Advance
shan
This is the code t display related contact associated with Account in button Click
Class
VF page
Hope this will help you,
Mark Best ANSWER if its works
Thanks
karthik
thanks
karthik.
VF Page:
<apex:page sidebar="false" controller="DiplayRelatedContacts">
<apex:sectionHeader title="contacts of accounts"/>
<apex:form>
<apex:pageBlock >
<apex:pageBlockSection title="Select the Account/Parent Name" >
<apex:actionRegion >
<apex:selectList value="{!selectParentRecID}" size="1" multiselect="false" >
<apex:actionSupport event="onchange" action="{!dispalyContact}" reRender="aj" />
<apex:selectOptions value="{!ListOfAccounts}"/>
</apex:selectList>
</apex:actionRegion>
</apex:pageBlockSection>
<!-- </apex:pageBlock >
<apex:pageBlock > -->
<apex:pageBlockButtons location="Top">
<apex:commandButton value="Display" action="{!dispalyContact}" /><!-- reRender="aj" -->
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!conList}" var="a" id="aj">
<apex:column headerValue="Child Name" value="{!a.Name}"/>
<apex:column headerValue="City" value="{!a.selflearning__city__c}"/>
<apex:column headerValue="Parent Name" value="{!a.selflearning__Parent_Object__r.name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Class:
public class DiplayRelatedContacts
{
public List<selflearning__Pobject__c> accList{get;set;}
public list<selflearning__Cobject__c> conList{get;set;}
public DiplayRelatedContacts()
{
//accList=[SELECT Id,Name FROM selflearning__Pobject__c LIMIT 10];
}
public PageReference dispalyContact() {
if(selectParentRecID != null)
conList=[SELECT id,name,selflearning__Parent_Object__r.name,selflearning__city__c FROM selflearning__Cobject__c WHERE selflearning__parent_object__c=:selectParentRecID];
return null;
}
public List<SelectOption> getListOfAccounts()
{
List<selflearning__Pobject__c> AccountList = [SELECT Id,Name FROM selflearning__Pobject__c] ;
System.debug('selflearning__Pobject__c: '+AccountList.size());
List<SelectOption> AccountOptionList = new List<SelectOption>();
AccountOptionList .add(new SelectOption( ' ' ,'---Select---'));
for(selflearning__Pobject__c acc : AccountList )
{
AccountOptionList.add(new SelectOption(acc.ID , acc.Name));
}
return AccountOptionList ;
}
public String selectParentRecID { get; set; }
}