+ Start a Discussion
Subhrajyoti NathSubhrajyoti Nath 

RecordSetVar in Visualforce Page

Hi guyz,

I am facing an issue with RecordSetvar as i am using Professional Edition and cannot use apex Classes. I have created a Visualforce page rendering only those records created by me using RecordSetVar which shows only 20 records per page, so i kept pagination which is working fine but my issue is If my record is not there in the first set of 20 records then first page is showing empty then i have to navigate to second page to see my records. I can use only one filter - 'All'. So please suggest me how to bring up the records to the first page or can i delte the pages which are showing empty to me. 

Thanks in advance
SFDC GuestSFDC Guest
Hi, 
Please find the below code.

<apex:page standardController="Account" recordSetvar="accounts">
<apex:sectionHeader title="Accounts"/>
  <apex:form id="theForm">
 <apex:pageBlock >
      <apex:pageBlockTable value="{!accounts}" var="a"   >
        <apex:column value="{!a.Name}"/>
           <apex:column value="{!a.AccountNumber}"/>
      </apex:pageBlockTable>
 
   <apex:pageBlockButtons >
      <apex:commandButton action="{!first}" value="First"/>
      <apex:commandButton action="{!previous}" value="Previous"/>
      <apex:commandButton action="{!next}" value="Next"/>
   
      <apex:commandButton action="{!last}" value="Last"/>
  </apex:pageBlockButtons>
 
  </apex:pageBlock>
   </apex:form> 
</apex:page>

Thank You.
 
SFDC GuestSFDC Guest
Hi,
Please use the below code filtering.
Here recordSetVar is used to retrieve all records. 
And below piece of code for listViews.
        <apex:selectList value="{!filterId}" size="1">
                        <apex:actionSupport event="onchange" rerender="opp_table"/>
                        <apex:selectOptions value="{!listviewoptions}"/>
                    </apex:selectList>

Complete VF page:
<apex:page standardController="Opportunity" recordSetVar="opportunities" 
              tabStyle="Opportunity"
    sidebar="false">
    <apex:form>
        <apex:pageBlock>
            <apex:pageMessages/>
            <apex:pageBlock>
                <apex:panelGrid columns="2">
                    <apex:outputLabel value="View:"/>
                    <apex:selectList value="{!filterId}" size="1">
                        <apex:actionSupport event="onchange" rerender="opp_table"/>
                        <apex:selectOptions value="{!listviewoptions}"/>
                    </apex:selectList>
                </apex:panelGrid>
            </apex:pageBlock>

            <apex:pageBlockButtons>
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!opportunities}" var="opp" id="opp_table">
                <apex:column value="{!opp.name}"/>
                <apex:column headerValue="Stage">
                    <apex:inputField value="{!opp.stageName}"/>
                </apex:column>
                <apex:column headerValue="Close Date">
                    <apex:inputField value="{!opp.closeDate}"/>
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Please mark it as best answer, if it is solved your problem.
Thank You,
Sohel Mohd