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
raji ch 8raji ch 8 

Write a visualforce page having 2 buttons Active and Inactive . When i click Active button Acitve records dispaly and click inacive records display?

SandhyaSandhya (Salesforce Developers) 
Hi,

Below is the sample code with checkbox as active,refer and change according to your requirement.
 
<apex:page controller="Account" sidebar="false" extensions="accountExtension">
    <apex:form >
    <apex:inputCheckbox value="{!activeAccountOnly}"/>
	<apex:commandButton value="Show Active Accounts" action="{!showActiveAccounts}" reRender="panelId"/>
    <apex:pageBlock >
        <apex:outputPanel id="panelId">
            <apex:pageblockTable value="{!accountList}" var="wrapRec" rendered="{!normalList}">
               <apex:column value="{!wrapRec.Name}" />
               <apex:column value="{!wrapRec.Id}"/>
          </apex:pageblockTable>
          
           <apex:pageblockTable value="{!accountList}" var="wrapRec" rendered="{!selectedList}">
               <apex:column value="{!wrapRec.Name}" />
               <apex:column value="{!wrapRec.Id}"/>               
          </apex:pageblockTable>
        </apex:outputPanel>      
    </apex:pageBlock>
    </apex:form>
</apex:page>
 
public class accountExtension{
	public List<Account> accountList{get;set;}
	public accountExtension(ApexPages.StandardController controller){
		accountList = [SELECT id ,Name FROM Account];
	}
	public boolean activeAccountOnly{get;set;}
	public void showActiveAccounts(){
        accountList = new List<myWrapperClass>();
        normalList = false;
        selectedList = true;
		if(activeAccountOnly == false)
		{
			accountList = [SELECT id ,Name FROM Account WHERE is_active__C =TRUE];
		}else{
			accountList = [SELECT id ,Name FROM Account];
		}
	}
}

Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
 
Best Regards
Sandhya
 
 
raji ch 8raji ch 8
Getting this Error
Error: accountExtension Compile Error: Illegal assignment from List<Account> to List<Account> at line 4 column 9