You need to sign in to do that
Don't have an account?
How to change focus between tabs in TAB PANEL
Scenario:
On click of button-'Add New B' in the TAB-'AChild' I want to move focus to tab-'BChild'.I have tried value attribute in tab panel but its not working.How can I achieve this?Please suggest.Thanks for your help in advance.
Page:
<apex:page controller="EditBCls">
<apex:form>
<apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab" >
<apex:tab label="A" style="font-size:15;font-weight:bold" >
<apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab" >
<apex:tab label="AChild" >
<apex:pageBlock >
<apex:pageblockButtons location="bottom" >
<apex:commandButton value="Add New B" action="{!addB}" />
</apex:pageblockButtons>
</apex:pageBlock >
</apex:tab>
</apex:tabPanel>
</apex:tab>
<apex:tab label="B">
<apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab">
<apex:tab label="BChild">
</apex:tab>
</apex:tabPanel>
</apex:tab>
</apex:tabPanel>
</apex:form>
</apex:page>
Hi,
Check the underlined part in the code. Use the name attribute in the second tab and use selectedTab. Here the selected tab name is hardcoded. Instead use a variable in the controller.
public string selectTab{get;set;}
In the method of Button click - make selectTab= 'BTAB';
selectedTab="{!selectTab}"
<apex:page controller="EditBCls">
<apex:form>
<apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab" selectedTab="BTAB">
<apex:tab label="A" style="font-size:15;font-weight:bold" >
<apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab" >
<apex:tab label="AChild" >
<apex:pageBlock >
<apex:pageblockButtons location="bottom" > <apex:commandButton value="Add New B" action="{!addB}" />
</apex:pageblockButtons>
</apex:pageBlock >
</apex:tab>
</apex:tabPanel>
</apex:tab>
<apex:tab label="B" name="BTAB">
<apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab" >
<apex:tab label="BChild">
</apex:tab>
</apex:tabPanel>
</apex:tab>
</apex:tabPanel>
</apex:form>
</apex:page>
Hope it helps.
Thanks
Sureka
Hi Sureka,
I am using following code,but focus is not going to tab-BChild on clicking button-Add New B:
<apex:page controller="EditBCls">
<apex:form>
<apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab" selectedTab="{!selectedSolutionTab}">
<apex:tab label="A" style="font-size:15;font-weight:bold" >
<apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab" >
<apex:tab label="AChild" >
<apex:pageBlock >
<apex:pageblockButtons location="bottom" >
<apex:commandButton value="Add New B" action="{!addB}" />
</apex:pageblockButtons>
</apex:pageBlock >
</apex:tab>
</apex:tabPanel>
</apex:tab>
<apex:tab label="B" name="solution">
<apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab">
<apex:tab label="BChild">
</apex:tab>
</apex:tabPanel>
</apex:tab>
</apex:tabPanel>
</apex:form>
</apex:page>
And Controller:
public with sharing class EditSolutioncls{
public string selectedSolutionTab {get;set;}
public string solution {get;set;}
public EditSolutioncls(ApexPages.StandardController controller){
}
Public void addB(){
selectedSolutionTab=solution;
}
}
Can you please check what I am missing?
Regards,
GG
Hi,
String 'Solution' is empty. Assign some value and then check.
Thanks
Sureka,
Now:
public with sharing class EditSolutioncls{
public string selectedSolutionTab {get;set;}
public string solution {get;set;}
public EditSolutioncls(ApexPages.StandardController controller){
solution='Test';
}
Public void addB(){
selectedSolutionTab=solution;
}
}
But not working.
Regards,
GG
Hi,
It should be solution='solution'; as your button name is solution. Please understand the difference, it is not the variable name. It is the variable value.
Use this
public string sol{get;set;}
sol = 'solution';
Thanks
Hi Sureka,
Page:
<apex:page controller="EditBCls">
<apex:form>
<apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab" selectedTab="{!selectedSolutionTab}">
<apex:tab label="A" style="font-size:15;font-weight:bold" >
<apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab" >
<apex:tab label="AChild" >
<apex:pageBlock >
<apex:pageblockButtons location="bottom" >
<apex:commandButton value="Add New B" action="{!addB}" />
</apex:pageblockButtons>
</apex:pageBlock >
</apex:tab>
</apex:tabPanel>
</apex:tab>
<apex:tab label="B" name="solution">
<apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab">
<apex:tab label="BChild">
</apex:tab>
</apex:tabPanel>
</apex:tab>
</apex:tabPanel>
</apex:form>
</apex:page>
++++++++++++++++++++++++++++++++
Controller:
public with sharing class EditSolutioncls{
public string selectedSolutionTab {get;set;}
public string sol {get;set;}
public EditSolutioncls(ApexPages.StandardController controller){
}
Public void addB(){
sol='Solution';
selectedSolutionTab=sol;
}
}
But not working.Please reply.
Regards,
GG