+ Start a Discussion
SRILAKSHMI BSRILAKSHMI B 

object list views as drop down list in Visualforce Page

Hi,

 

I have created custom list view button on the opportunity object.When that button is cliecked it will be navigated to VF page where it shows two drop down list.One shows list views available for the Opportunity object and anothe dropdown shows list view available for another custom object.

 

Requirement is depending on the view selcted by the user in  the VF page for opportunity list view dropdown  and custom object list view dropdown  the conroller class has to fetch records from the both the objects belong to the view selcted by the user and do some custom modification.

 

vf page code:

 

<apex:page standardController="Opportunity" extensions="showOpptyaddress" sidebar="false" recordSetVar="Opportunities" id="pageid">


 <apex:form id="Form">
             
            <apex:outputLabel value="Opportunities View: "/>
              
              <apex:selectList value="{!oppsList.filterId}" size="1">
                <apex:actionSupport event="onchange" rerender="Form" />
                <apex:selectOptions value="{!oppsList.listviewoptions}"/>
            </apex:selectList>
            <br/><br/>
            
            <apex:outputLabel value="Custom object View: "/>
            
            <apex:selectList value="{!customobjectList.filterId}" size="1">
                <apex:actionSupport event="onchange" rerender="Form" />
                <apex:selectOptions value="{!customobjectList.listviewoptions}"/>
            </apex:selectList>
</apex:form>

</apex:page>

 

 

Controller code:

 

 

public with sharing class showOpptyaddress {

ApexPages.StandardSetController setCon;
         
         
    
        public ApexPages.StandardSetController oppsList {get; private set;}
        public ApexPages.StandardSetController customobjectList {get; private set;}
        

          public showOpptyaddress ()
           {
   
           }
       
       

         public showOpptyaddress (ApexPages.StandardSetController controller)
         {
    
             
     
             customobjectList = new ApexPages.StandardSetController
                (Database.getQueryLocator([
                Select Name,Id from customobject
               ]));
             
                   //Opportuities List
             oppsList = new ApexPages.StandardSetController
              (Database.getQueryLocator([
                Select o.id, o.Name, o.Account.Id, o.Account.Name
                From Opportunity o
              ]));
          }

 

 

Can anyone please suggest how this could be acheived.

 

Thanks,

Srilakshmi B