You need to sign in to do that
Don't have an account?

Need to show child records in 2 tables one with records having picklist value as A and other table with B value to show in parent record
Hi All,
I have a requirement where i am displaying child object records in parent record detail page using standard controller and extensions.But the problem is
in child object there is a picklist field Level with values High and low. I need 2 tables to display in the VF page one table with child Records
having High as values and the other table with records having Low as value from the child records.Below code which i am sharing is just i am getting
the record values in pageblock table but i am not sure how to display both the tables which holds different picklist values (High and Low).
Please suggest me how to differentiate the child records based on picklist values from the saved child records and also i have a picklist as Year is it possible to showrecords only for the current year by converting picklist to date ?
Controller:
public with sharing class SampleClass{
Public Id accId;
Public List<Contact> con{get;set;}
public SampleClass(ApexPages.StandardController controller) {
accId=[SELECT Id,Name FROM Account WHERE id=:ApexPages.CurrentPage().getparameters().get('id')];
con=[Select Id,Name,Account,Level__c from Account where AccountId= :accId];
}
}
VF page:
<apex:page standardcontroller="Account" extensions="SampleClass">
<apex:Form >
<apex:pageBlock title="contact details">
<apex:pageBlockTable value="{!con}" var="a" style="width:100%" rendered="{!con.Level__c=='High'}">
<apex:outputText value="High Level Records"/>
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.Level__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:Form>
</apex:page>
Thanks in advance.
I have a requirement where i am displaying child object records in parent record detail page using standard controller and extensions.But the problem is
in child object there is a picklist field Level with values High and low. I need 2 tables to display in the VF page one table with child Records
having High as values and the other table with records having Low as value from the child records.Below code which i am sharing is just i am getting
the record values in pageblock table but i am not sure how to display both the tables which holds different picklist values (High and Low).
Please suggest me how to differentiate the child records based on picklist values from the saved child records and also i have a picklist as Year is it possible to showrecords only for the current year by converting picklist to date ?
Controller:
public with sharing class SampleClass{
Public Id accId;
Public List<Contact> con{get;set;}
public SampleClass(ApexPages.StandardController controller) {
accId=[SELECT Id,Name FROM Account WHERE id=:ApexPages.CurrentPage().getparameters().get('id')];
con=[Select Id,Name,Account,Level__c from Account where AccountId= :accId];
}
}
VF page:
<apex:page standardcontroller="Account" extensions="SampleClass">
<apex:Form >
<apex:pageBlock title="contact details">
<apex:pageBlockTable value="{!con}" var="a" style="width:100%" rendered="{!con.Level__c=='High'}">
<apex:outputText value="High Level Records"/>
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.Level__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:Form>
</apex:page>
Thanks in advance.
Please use the below class and VF page:
<apex:page standardcontroller="Account" extensions="SampleClass">
<apex:Form >
<apex:pageBlock title="contact details">
<apex:pageBlockSection title="High Level Records" collapsible="false">
<apex:pageBlockTable value="{!con}" var="a" style="width:100%">
<apex:column value="{!a.Name}" rendered="{!a.Level__c=='High'}"/>
<apex:column value="{!a.Level__c}" rendered="{!a.Level__c=='High'}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection title="Low Level Records" collapsible="false">
<apex:pageBlockTable value="{!con}" var="a" style="width:100%">
<apex:column value="{!a.Name}" rendered="{!a.Level__c=='Low'}"/>
<apex:column value="{!a.Level__c}" rendered="{!a.Level__c=='Low'}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:Form>
</apex:page>
=================
public class SampleClass {
public List<Contact> con{get;set;}
Public Account acc;
public SampleClass(ApexPages.StandardController controller) {
this.acc= (Account)controller.getRecord();
con = [Select Id,Level__c,Name from Contact where AccountId =: acc.Id];
}
}
Thanks,
Maharajan.C