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
Srinivas NimmagaddaSrinivas Nimmagadda 

How to write code for List View Option in Visual force Page

Hi, 
I am trying to recreate ACCOUNT object page in my custom visual force page.

Now I would like to know how to code for LIST VIEW OPTIONS, so that when ever we change the value the records in the pageblock section changes as selected.

Account Custom VisualForce PageList View Options

Code:
<!--
Author		: Srini
Description	: Create Account Object Duplicate Page
Version		: V1.0
CreatedDate	: 05-15-2019
-->
<apex:page standardController="Account" recordSetVar="accounts" tabStyle="account">
    <apex:form >
    <apex:sectionHeader title="Accounts" subtitle="Home" help="Account Page Help!"/>

<!-- VIEW -->	
<!--    <apex:pageBlock mode="maindetail"> -->
    	&nbsp; <b>View:</b> &nbsp;
        <apex:selectList value="{!filterId}" size="1">
<!-- ACTIONSUPPORT -- When View Option is changed we have to refresh below Page to change those values -->
        	<apex:actionSupport event="onchange" reRender="thechart"/>    
            <apex:selectOptions value="{!listviewoptions}" />
        </apex:selectList> &nbsp;
        <apex:commandButton id="go" value="Go!" title="Go" styleClass="buttonStyle" style="color:green"/> &nbsp;
        <apex:commandLink value="Edit"/> | &nbsp;
        <apex:commandLink value="Create New View"/> <br/> <br/>
<!--    </apex:pageBlock> -->

<!-- RECENT ACCOUNT -->    
    <apex:pageBlock title="Recent Accounts" mode="detail" tabStyle="dashboard">
    	<apex:pageBlockButtons location="top">
        	<apex:commandButton value="New" title="New Account" id="NAB" styleClass="buttonstyle" style="color:darkblue" />
       		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	
            <apex:selectList value="{!filterId}" size="1">
                <apex:actionSupport event="onchange" reRender="thechart"/>
	            <apex:selectOption itemLabel="Recently Created" itemValue="" id="RC">			</apex:selectOption>
                <apex:selectOption itemLabel="Recently Modified" itemValue="" id="RM">			</apex:selectOption>
                <apex:selectOption itemLabel="Recently Viewed" itemValue="" id="RV">			</apex:selectOption>
			</apex:selectList>
        </apex:pageBlockButtons>
        <apex:pageBlockTable value="{!accounts}" var="acc" rows="5">
<!--            <apex:column headerValue="Account Name">
                <apex:outputLink value="{!acc.name}">{!acc.name}</apex:outputLink>
			</apex:column>
-->
            	<apex:column value="{!acc.name}"/>
                <apex:column value="{!acc.Id}"/>      	          	    
    	        <apex:column value="{!acc.Type}"/>
        </apex:pageBlockTable> 
        <apex:inlineEditSupport />
    </apex:pageBlock>

<!-- REPORTS -->       
    <apex:pageBlock mode="maindetail">
        <apex:pageBlockSection columns="2">
            <apex:pageBlock title="Reports" mode="detail" tabStyle="case" helpTitle="Reports Help !" helpUrl="/apex/VFpage_1">
                <apex:pageBlockSection columns="1">
                    <apex:commandLink value="Active Accounts"/>
                    <apex:commandLink value="Accounts with last activity > 30 days"/>
                    <apex:commandLink value="Account Owners"/>
                    <apex:commandLink value="Contact Role Report"/>
                    <apex:commandLink value="Account History Report"/>
                    <apex:commandLink value="Partner Accounts"/>   
                </apex:pageBlockSection> <br/>
                <apex:pageBlock mode="detail" tabStyle="opportunity">
                    <apex:commandLink value="Go to Reports"/>
                </apex:pageBlock>
            </apex:pageBlock>
            
<!-- TOOLS -->        
            <apex:pageBlock title="Tools" mode="detail" tabStyle="order" helpTitle="Tools Help !" helpUrl="/apex/VFpage_2">
            	<apex:pageBlockSection columns="1">
                    <apex:commandLink value="Import Accounts & Contacts"/>
					<apex:commandLink value="Mass Delete Accounts"/>
					<apex:commandLink value="Transfer Accounts"/>
					<apex:commandLink value="Merge Accounts"/>
					<apex:commandLink value="Mass Reassign Account Teams"/>
					<apex:commandLink value="Sales Methodologies"/>                    
                </apex:pageBlockSection>    
            </apex:pageBlock>
        </apex:pageBlockSection>
	</apex:pageBlock>        
 </apex:form>   
</apex:page>

 
Best Answer chosen by Srinivas Nimmagadda
sumithasumitha
Hi,

Please use <apex:enhancedList>.
Eg.,
<apex:page>
    <apex:enhancedList type="Account" rowsPerPage="25" height="500" width="1000"/>
</apex:page>

Thanks,
Sumitha