How to display the records based on choosen picklist value(with out button) in visualforce

<apex:page controller="AccountController2" showHeader="false">
 <apex:slds />
 <apex:pageMessages />
<apex:form id="test">
<apex:selectList size="1"    style="width:10%;" value="{!selectedIndustry}" styleClass="slds-input" rendered="{!isclicked==false}">   
            <apex:selectOptions value="{!AccountIndPickValues}"  /> 
            <apex:actionSupport event="onchange" action="{!searchAccountRecords}"/>
        </apex:selectList> <br/><br/>
        <apex:outputpanel rendered="{!isclicked==true && acc_list.size!=0}" >
<table class="slds-table"  width="100%"  align="center">
<tr>
  <td style="width:7%;"><b>S.No</b></td>
  <td style="width:7%;"><b>Name</b></td>
  <td style="width:7%;"><b>Site</b></td>
  <td style="width:7%;"><b>AccountNumber </b></td>
  <td><b>Industry</b></td>
  <apex:variable value="{!0}" var="index" />
</tr>
<apex:repeat value="{!acc_list}" var="Items">
  <tr>
  <td>
   <apex:variable value="{!index + 1}" var="index" />
{!index} 
  </td>
  <td>
  <apex:outputText value="{!Items.Name}"/>
  </td>
  <td>
  <apex:outputText value="{!Items.Site}"/>
  </td>
  <td>
  <apex:outputText value="{!Items.AccountNumber }"/>
  </td>
  <td>
  <apex:outputText value="{!Items.Industry}"/>
  </td>
</tr>
</apex:repeat> 

 
   </table>   
</apex:outputpanel>
</apex:form>
</apex:page>


public class AccountController2
{
    public string selectedIndustry{set;get;}
    public List<Account> acc_list{set;get;}
    public boolean isclicked{set;get;}
    public AccountController2()
    {
        getAccountIndPickValues();
        isclicked=false;
    }
    public List<SelectOption> getAccountIndPickValues()
    {
        List<SelectOption> options = new List<SelectOption>();
        Schema.DescribeFieldResult fieldResult = Account.Industry.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        options.add(new SelectOption('','--None--'));
        for(Schema.PicklistEntry f : ple)
        {
            options.add(new SelectOption(f.getLabel(), f.getValue()));
        }
        return options;         
    }
    public void searchAccountRecords()
    {
        isclicked=true;
        acc_list=[select Name,Site,AccountNumber,Industry from Account where Industry=:selectedIndustry];
        if(acc_list.size()==0)
        {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'No Records found'));

        }

    }
}




























Comments