+ Start a Discussion
Siarhei balantsevichSiarhei balantsevich 

My paginator doesen't work Help

apex 
public with sharing class app_test_1 {

 public Appointment__c appt {get; set;}
    public string Doc_name {get;set;}
    public string Patient_name {get;set;}
    public List<Doctor__c>  doclists{set;get;}
    public String selectedDoctor {get; set;}
    public String selectedPatient {get; set;}
    public Datetime appDate {get; set;}
    public List<Doctor__c> DoctorList {get;set;}
    public List<SelectOption> doctorSelectOptionList {get;set;}
    public List<Patient__c> PatientList {get;set;}
    public List<SelectOption> patientSelectOptionList {get;set;} 
    public List<Appointment__c> appList {get;set;} 
    public string str_1 {get;set;}
    Public Integer size{get;set;} 
    Public Integer noOfRecords{get; set;} 
    public List<SelectOption> paginationSizeOptions{get;set;}
    
    public app_test_1(){
        
        
        
        str_1='kukla';
        Patient_name = 'a015g00000KIFvGAAX';
        appt=new Appointment__c();
     //   getApp();
         doctorSelectOptionList = new List<SelectOption>();
        patientSelectOptionList = new List<SelectOption>();
     
       
        DoctorList = [SELECT iD, Name,working_hours_start__c FROM Doctor__c];
        //TimeStart = DoctorList.working_hours_start__c;
        for (Doctor__c doc : DoctorList){ 
            doctorSelectOptionList.add(new SelectOption(doc.Id, doc.Name)); 
        }
             
        PatientList = [SELECT Id, Name FROM Patient__c];
        for (Patient__c patient : PatientList){
            patientSelectOptionList.add(new SelectOption(patient.Id, patient.Name)); 
        }
        
         size=10;
        paginationSizeOptions = new List<SelectOption>();
        paginationSizeOptions.add(new SelectOption('5','5'));
        paginationSizeOptions.add(new SelectOption('10','10'));
        paginationSizeOptions.add(new SelectOption('20','20'));
        paginationSizeOptions.add(new SelectOption('50','50'));
        paginationSizeOptions.add(new SelectOption('100','100'));
        
    }
    
    
public PageReference save() {
return null;
}

public PageReference saveandnew() {
     Doc_name = selectedDoctor;
    appt.Doctor__c=selectedDoctor;
    appt.patient__c=Patient_name;
insert appt;

PageReference PageRef = new PageReference('/apex/vs_g_t_01');
appt.clear();
return PageRef;
}
    
    
    
       public list<Doctor__c> getDoc()
    {
       return [Select Name, working_hours_start__c,Working_Hours_End__c From Doctor__c
              where Name Like :str_1];
           
    }

    
    
     public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {                
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                      [select ID,NAme,Doctor__r.Name,patient__r.Name,Duration_in_minutes__c	,Appointment_Data__c	FROM Appointment__c]));
                setCon.setPageSize(size);  
                noOfRecords = setCon.getResultSize();
            }            
            return setCon;
        }
        set;
    }
     
    //Changes the size of pagination
    public PageReference refreshPageSize() {
         setCon.setPageSize(size);
         return null;
    }
 
    // Initialize setCon and return a list of record    
     
    public List<Appointment__c> getOpportunities() {
         return (List<Appointment__c>) setCon.getRecords();
    }
    
  
    
    
}

vsf
 
<apex:page controller="app_test_1">
    
    <apex:form >
        
<apex:pageBlock title="appointment">
    
    <!-- Select a doctor -->
<apex:pageBlockSection >
 Select a doctor:
<apex:selectList size="1" multiselect="false" value="{!selectedDoctor}">
<apex:selectOptions value="{!doctorSelectOptionList}"/>

</apex:selectList>
</apex:pageBlockSection>
    
    
   
<apex:pageBlock>

  <apex:pageBlockTable value="{!doc}" var="item">
       <apex:column value="{!item.working_hours_start__c}"/>
  </apex:pageBlockTable> 
 <apex:pageBlockTable value="{!doc}" var="item">
       <apex:column value="{!item.Working_Hours_End__c}"/>
  </apex:pageBlockTable> 
</apex:pageBlock>

    
    
    
<!-- Select a patient -->
<apex:pageBlockSection >
Select a patient:
<apex:selectList size="1" value="{!selectedPatient}">
<apex:selectOptions value="{!patientSelectOptionList}"/>
</apex:selectList>
</apex:pageBlockSection>
    
    
    
     <apex:pageBlockSection >
                <apex:inputField label="Duration in minutes" 
                            value="{!appt.Duration_in_minutes__c}"
                            required="true"/>
            </apex:pageBlockSection>
    
    
    <!-- Appointment date -->
<apex:pageBlockSection >
<apex:inputField label="Appointment date" 
                 value="{!appt.Appointment_Data__c}"
required="true"/>
</apex:pageBlockSection>
   
          <apex:pageBlockButtons >
    <apex:commandButton value="Save" action="{!save}" />
    <apex:commandButton value="Save & New" action="{!saveandnew}" />
    <apex:commandButton value="Cancel" action="/apex/Registration" immediate="true" />
    </apex:pageBlockButtons>
        
        
        </apex:pageBlock>
        <script type="text/javascript">
console.log('{!selectedDoctor}');
</script>  
    
        
        
              <apex:actionFunction name="refreshPageSize" action="{!refreshPageSize}" status="fetchStatus" reRender="pbId"/>
        <apex:pageBlock id="pbId">
            <apex:pageBlockSection title="All Opportunities" collapsible="false" columns="1">
                <apex:pageBlockTable value="{!Opportunities}" var="oppObj">
                     
                    <apex:column headerValue="Opportunity Name">
                        <apex:outputField value="{!oppObj.Name}"/>
                    </apex:column>
                     
                    <apex:column headerValue="Account Name">
                        <apex:outputField value="{!oppObj.Doctor__r.Name}"/>
                    </apex:column>
                     
                    <apex:column headerValue="Amount">
                        <apex:outputField value="{!oppObj.patient__r.Name}"/>
                    </apex:column>
                     
                    
                     
                    <apex:column headerValue="Close Date">
                        <apex:outputField value="{!oppObj.Appointment_Data__c}"/>
                    </apex:column>
                </apex:pageBlockTable>
                 
                <apex:panelGrid columns="8"> 
                 
                <apex:selectList value="{!size}" multiselect="false" size="1" onchange="refreshPageSize();">
                    <apex:selectOptions value="{!paginationSizeOptions}"/>
                </apex:selectList>
                 
                <apex:commandButton status="fetchStatus" reRender="pbId" value="First" action="{!setCon.first}" disabled="{!!setCon.hasPrevious}" title="First Page"/> 
  
                <apex:commandButton status="fetchStatus" reRender="pbId" value="Previous" action="{!setCon.previous}" disabled="{!!setCon.hasPrevious}" title="Previous Page"/> 
  
                <apex:commandButton status="fetchStatus" reRender="pbId" value="Next" action="{!setCon.next}" disabled="{!!setCon.hasNext}" title="Next Page"/> 
  
                <apex:commandButton status="fetchStatus" reRender="pbId" value="Last" action="{!setCon.last}" disabled="{!!setCon.hasNext}" title="Last Page"/> 
  
                <apex:outputText >{!(setCon.pageNumber * size)+1-size}-{!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,
                     (setCon.pageNumber * size))} of {!noOfRecords}
                </apex:outputText> 
                       
                <apex:outputPanel >                      
                    <apex:actionStatus id="fetchStatus" >
                        <apex:facet name="start" >
                          <img src="/img/loading.gif" />                    
                        </apex:facet>
                    </apex:actionStatus>
                </apex:outputPanel> 
  
            </apex:panelGrid>  
            </apex:pageBlockSection>
        </apex:pageBlock>
    
    </apex:form>
    </apex:page>

​​​​​​​
PriyaPriya (Salesforce Developers) 

Hi Siarhei balantsevich,

Can you please let us know what error you are getting ?

Regards,

Priya Ranjan

Siarhei balantsevichSiarhei balantsevich
I already figured it out. i change required="true"/> at required = false
PriyaPriya (Salesforce Developers) 
Great Work !!