function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
aditya3aditya3 

Dynamic Query with displaying of records

Hi all ,

I am working with pagination task,Here I am facing the problem is  create a textbox  [inside the text box if I enter 5  means it displays 5 records]
Below is my code ,How can I achieve this ?please help me ?


<apex:page standardController="Account" recordSetVar="Accounts" sidebar="false" extensions="cont" >
   
      <!--<apex:sectionHeader title="My Accounts" subtitle="Account Management"/> -->
       <apex:form >
          <apex:pageBlock >
            <apex:pageMessages id="error" />
              <apex:panelGrid columns="7" id="buttons">
                  <apex:commandButton action="{!Save}" value="Save"/>
                  <apex:commandButton action="{!Cancel}" value="Cancel"/>
                  <!--<apex:inputHidden /> -->
                  <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasprevious}" action="{!First}" value="First"/>
                  <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasprevious}" action="{!Previous}" value="Previous"/>
                  <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasnext}" action="{!Next}" value="Next"/>
                  <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasnext}" action="{!Last}" value="Last"/>
              </apex:panelGrid>
              <apex:pageBlockSection id="blocktable" >
                  <apex:pageBlockTable value="{!Accounts}" var="t">
                      <apex:column headerValue="Account" value="{!t.Name}" />
                      <apex:column headerValue="Phone" value="{!t.Phone}" />
                        <apex:column headerValue="Industry" value="{!t.Industry}" />
                         <apex:column headerValue="Rating" value="{!t.Rating}" />
                      
                    <!--  <apex:column headerValue="Priority">
                          <apex:outputField value="{!t.Priority__c}" />
                      </apex:column> --->
                      
   
                      
                      <apex:inlineEditSupport event="onClick"/>
                  </apex:pageBlockTable>
              </apex:pageBlockSection>  
              
              
          </apex:pageBlock>
      </apex:form>
  </apex:page>

 
Bhanu MaheshBhanu Mahesh
Hi Aditya,

Try below code

VF Page
<apex:page standardController="Account" recordSetVar="Accounts" sidebar="false" extensions="cont" >
   
      <!--<apex:sectionHeader title="My Accounts" subtitle="Account Management"/> -->
       <apex:form >
           <apex:inputText value="{!rows}"/>
           <apex:commandButton value="Submit" reRender="blocktable"/>
          <apex:pageBlock >
            <apex:pageMessages id="error" />
              <apex:panelGrid columns="7" id="buttons">
                  <apex:commandButton action="{!Save}" value="Save"/>
                  <apex:commandButton action="{!Cancel}" value="Cancel"/>
                  <!--<apex:inputHidden /> -->
                  <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasprevious}" action="{!First}" value="First"/>
                  <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasprevious}" action="{!Previous}" value="Previous"/>
                  <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasnext}" action="{!Next}" value="Next"/>
                  <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasnext}" action="{!Last}" value="Last"/>
              </apex:panelGrid>
              <apex:pageBlockSection id="blocktable" >
                  <apex:pageBlockTable value="{!Accounts}" var="t" rows="{!rows}">
                      <apex:column headerValue="Account" value="{!t.Name}" />
                      <apex:column headerValue="Phone" value="{!t.Phone}" />
                        <apex:column headerValue="Industry" value="{!t.Industry}" />
                         <apex:column headerValue="Rating" value="{!t.Rating}" />
                      
                    <!--  <apex:column headerValue="Priority">
                          <apex:outputField value="{!t.Priority__c}" />
                      </apex:column> --->
                      
   
                      
                      <apex:inlineEditSupport event="onClick"/>
                  </apex:pageBlockTable>
              </apex:pageBlockSection>  
              
              
          </apex:pageBlock>
      </apex:form>
  </apex:page>

Extension:
 
public class cont {

    public Integer rows{get;set;}
    public cont(ApexPages.StandardSetController controller) {

    }

}

Mark this question as "SOLVED" if your query is answered

Thanks & Regards,
Bhanu Mahesh Gadi