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
sfdcttslsfdcttsl 

Picklist value not refresing the result set for the second tme

Hi,

 

My requirement is to give a dropdown to the user and based on the selected value, a table has to be displayed.

 

If the dropdown value is changed, then the result set also should get changed.

 

The problem is whenever the drop down value is selected for the firsttime, the corresponding result set is shown. But whenever the dropdown value is changed for the second time, corresponding result set is not getting refreshed.

 

 

VFPAGE:

 

<apex:page StandardController="User" Extensions="UserData" tabstyle="User" sidebar="false">
  <apex:form >
  <apex:pageBlock title="Select Users" id="USERSLIST" mode="edit">
    <h1>Update Sales Co-ordinator for the users in Particular Region</h1>
  <br></br>
  <br></br>
      
   <apex:outputLabel value="Select Region of the user: " for="viewlist" />
<apex:inputField id="startMode" value="{!User.Region__c}">
<apex:actionsupport event="onchange" action="{!doSearch}" rerender="theTable" />
</apex:inputfield>
  
           <br></br>
   <apex:pageBlockTable value="{!results}" var="t" id="theTable">
        <apex:column >
          <apex:inputCheckbox value="{!User.ManagerId}" id="checkedone">
          </apex:inputCheckbox>
        </apex:column>
        <apex:column value="{!t.Name}"/>
        <apex:column value="{!t.Email}"/>
        <apex:column value="{!t.Region__c}"/>
        <apex:column value="{!t.Manager__c}"/>     
  </apex:pageBlockTable>
 

      
    </apex:pageblock>   
  </apex:form>
  </apex:page>

 

CONTROLLER:

 

public class UserData {
List<Userwrapper> userList {get;set;}
PUBLIC String usr{get;set;}
List<User> results=new List<User>();
public User user;
public ApexPages.StandardController stdCtrl;
public UserData(ApexPages.StandardController controller)
   {
     stdCtrl=controller;

   }  
    
        
  public Pagereference doSearch()
     {
      //results = [select Name,Region__c,Email,LanguageLocaleKey,Manager__c from User Where Region__c =:User.Region__c];
      User u=(User)stdCtrl.getrecord();
      results = [select Name,Region__c,Email,LanguageLocaleKey,Manager__c from User Where Region__c =:u.Region__c];

      system.debug('USERSLISTFOR REGION$$$$'+results);
      return null;
     }
   
     
   public List<User> getResults()
    {
        return results;
    }
 
 }

 

Please check and suggest if there are any ideas.

 

Thanks,

Ranjita.

 

Best Answer chosen by Admin (Salesforce Developers) 
jungleeejungleee

Hi,

 

Try adding a <apex:actionRegion> tag and then check if the table is refreshed again.

 

<apex:actionRegion>
	<apex:outputLabel value="Select Region of the user: " for="viewlist" />
	<apex:inputField id="startMode" value="{!User.Region__c}">
	<apex:actionsupport event="onchange" action="{!doSearch}" rerender="theTable" />
	</apex:inputfield>
</apex:actionRegion>

 -Sam

 

 

All Answers

jungleeejungleee

Hi,

 

Try adding a <apex:actionRegion> tag and then check if the table is refreshed again.

 

<apex:actionRegion>
	<apex:outputLabel value="Select Region of the user: " for="viewlist" />
	<apex:inputField id="startMode" value="{!User.Region__c}">
	<apex:actionsupport event="onchange" action="{!doSearch}" rerender="theTable" />
	</apex:inputfield>
</apex:actionRegion>

 -Sam

 

 

This was selected as the best answer
sfdcttslsfdcttsl

Thanks for the reply its working now....