You need to sign in to do that
Don't have an account?
harshasfdc
controlling using selectlist component
Hi All,
Is this possibel to show different pageblocktables on selecting a value in selectlist .i have to groups groupa and groupb on selecting groupa i have to display one pageblocktable corrsponding to groupa on selecting gropub i have to show groupb value in the same page.
Thanks,
Harsha
Hi,
Try the below code snippet as reference:
<apex:page id="p1" controller="examples37">
<apex:form id="f1" >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:selectList value="{!countries}" onclick="check(this)" >
<apex:selectOptions value="{!items}"/>
</apex:selectList>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock id="pb1" >
<apex:pageBlockSection columns="4">
<apex:pageBlockTable value="{!Account}" var="a">
<apex:column headerValue="test1"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock id="pb2">
<apex:pageBlockSection >
<apex:pageBlockTable value="{!Account}" var="b">
<apex:column headerValue="test2"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<script>
function check(getpicklistval)
{
alert(getpicklistval.value);
if(getpicklistval.value=='groupa')
{
document.getElementById('p1:f1:pb1').style.display='block';
document.getElementById('p1:f1:pb2').style.display='none';
}
else
{
document.getElementById('p1:f1:pb1').style.display='none';
document.getElementById('p1:f1:pb2').style.display='block';
}
return false;
}
</script>
</apex:form>
</apex:page>
..............................
Controller
..............................
public class examples37 {
public List<Account>Account{get;set;}
String[] countries = new String[]{};
public List<Account> getAccount() {
Account acc=[select name from Account];
return Account;
}
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('groupa','groupa'));
options.add(new SelectOption('groupb','groupb'));
return options;
}
public String[] getCountries() {
return countries;
}
public void setCountries(String[] countries) {
this.countries = countries;
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
All Answers
Hi,
Try the below code snippet as reference:
<apex:page id="p1" controller="examples37">
<apex:form id="f1" >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:selectList value="{!countries}" onclick="check(this)" >
<apex:selectOptions value="{!items}"/>
</apex:selectList>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock id="pb1" >
<apex:pageBlockSection columns="4">
<apex:pageBlockTable value="{!Account}" var="a">
<apex:column headerValue="test1"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock id="pb2">
<apex:pageBlockSection >
<apex:pageBlockTable value="{!Account}" var="b">
<apex:column headerValue="test2"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<script>
function check(getpicklistval)
{
alert(getpicklistval.value);
if(getpicklistval.value=='groupa')
{
document.getElementById('p1:f1:pb1').style.display='block';
document.getElementById('p1:f1:pb2').style.display='none';
}
else
{
document.getElementById('p1:f1:pb1').style.display='none';
document.getElementById('p1:f1:pb2').style.display='block';
}
return false;
}
</script>
</apex:form>
</apex:page>
..............................
Controller
..............................
public class examples37 {
public List<Account>Account{get;set;}
String[] countries = new String[]{};
public List<Account> getAccount() {
Account acc=[select name from Account];
return Account;
}
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('groupa','groupa'));
options.add(new SelectOption('groupb','groupb'));
return options;
}
public String[] getCountries() {
return countries;
}
public void setCountries(String[] countries) {
this.countries = countries;
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi Ankit
Thank's for the reply it helped me a lot
Thanks,
Harsha