Hi Praveen,Here is a similar post.https://developer.salesforce.com/forums/ForumsMain?id=906F0000000BFqzIAGYou can use following code PAGE
<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>
CONTROLLER
Don't forget to select best answer to make our efforts visible in the developer forum.Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can helppublic 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];
}
}
}
3 answers