+ Start a Discussion
basha skbasha sk 

how to display standard object records into two sections based on field sepeartion?

    Hi Everyone,
    
             I have a custon object called Test__c.I'm trying to display Test__c object records into two sections
             in a visualforce based on a field sepeartion.but how to read the fields from cotroller extension.
            
             vf page
             -------
            
             <apex:page standardController="Test__c" extensions="DivedeRecordsList" recordSetVar="test" >
                <apex:sectionHeader title="Test Records List" />
                <apex:form >   

                 <apex:pageBlock Title="Test Records completed">
                  <apex:pageBlockTable value="{!test}" var="w" >                     
                    <apex:column value="{!w.first}" />
                    <apex:column value="{!w.Second}" />
                    <apex:column value="{!w.third}" />
                    <apex:column value="{!w.Expired__c}" />
                  </apex:pageBlockTable>
                 </apex:pageBlock>    
                
               <apex:pageBlock Title="New Test Records">  
                <apex:pageBlockTable value="{!test}" var="w" >     
                    <apex:column value="{!w.first}" />
                    <apex:column value="{!w.Second}" />
                    <apex:column value="{!w.third}" />    
                    <apex:column value="{!w.Expired__c}" />
              </apex:pageBlock>   
              
             </apex:form>
            </apex:page>

            Apex class
            -----------


            public class DivedeRecordsList {
                public Test__c testrecords{get;set;}
                List<Test__c> lst{get;set;}
                List<Test__c> lst1{get;set;}
                
                public DivedeWebinarsList(ApexPages.StandardController controller){
                     testrecords = (Test__c)controller.getRecord();
                    
                }

                public  List<Test__c> upcomingRecords(){
                    
                    List<Test__c> lst = [select id,Name,first,second,third from Test__c where Expired__c = 'false'];
                    return lst;
                }
                public  List<Test__c> completedRecords(){
                    
                    List<Test__c> lst = [select id,Name,first,second,third from Test__c where Expired__c = 'true'];
                    return lst;
                }
            }

            Thanks In advance
            Sekhar
Best Answer chosen by basha sk
NagendraNagendra (Salesforce Developers) 
Hi Basha,

You can make following code changes:

Change APEX method names to following:

1. public List getupcomingRecords()
2. public List getcompletedRecords()

Update your VF page as:
<apex:page standardController="Test__c" extensions="DivedeRecordsList" recordSetVar="test" >
            <apex:sectionHeader title="Test Records List" />
            <apex:form >   

             <apex:pageBlock Title="Test Records completed">
              <apex:pageBlockTable value="{!upcomingRecords}" var="w" >                     
                <apex:column value="{!w.first}" />
                <apex:column value="{!w.Second}" />
                <apex:column value="{!w.third}" /> 
                <apex:column value="{!w.Expired__c}" /> 
              </apex:pageBlockTable> 
             </apex:pageBlock>    

           <apex:pageBlock Title="New Test Records">  
            <apex:pageBlockTable value="{!completedRecords}" var="w" >     
                <apex:column value="{!w.first}" />
                <apex:column value="{!w.Second}" />
                <apex:column value="{!w.third}" />    
                <apex:column value="{!w.Expired__c}" /> 
          </apex:pageBlock>   

         </apex:form>
        </apex:page>
Thanks,
Nagendra.

 

All Answers

NagendraNagendra (Salesforce Developers) 
Hi Basha,

You can make following code changes:

Change APEX method names to following:

1. public List getupcomingRecords()
2. public List getcompletedRecords()

Update your VF page as:
<apex:page standardController="Test__c" extensions="DivedeRecordsList" recordSetVar="test" >
            <apex:sectionHeader title="Test Records List" />
            <apex:form >   

             <apex:pageBlock Title="Test Records completed">
              <apex:pageBlockTable value="{!upcomingRecords}" var="w" >                     
                <apex:column value="{!w.first}" />
                <apex:column value="{!w.Second}" />
                <apex:column value="{!w.third}" /> 
                <apex:column value="{!w.Expired__c}" /> 
              </apex:pageBlockTable> 
             </apex:pageBlock>    

           <apex:pageBlock Title="New Test Records">  
            <apex:pageBlockTable value="{!completedRecords}" var="w" >     
                <apex:column value="{!w.first}" />
                <apex:column value="{!w.Second}" />
                <apex:column value="{!w.third}" />    
                <apex:column value="{!w.Expired__c}" /> 
          </apex:pageBlock>   

         </apex:form>
        </apex:page>
Thanks,
Nagendra.

 
This was selected as the best answer
basha skbasha sk
@Thanks Nagendra It Works perfectly.