You need to sign in to do that
Don't have an account?
Vadivel Murugan
Dependency Picklist
MY VF PAGE:
<apex:page standardController="Engineer_Checklist__c" extensions="sparedetail">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="5" title="Spare Details">
<apex:pageblockSectionItem >
<apex:selectList size="1" multiselect="false" value="{!selspare}">
<apex:selectOptions value="{!Spare}"/>
<apex:actionSupport event="onchange" reRender="a"/>
</apex:selectList>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:selectList size="1" multiselect="false" value="{!sparedetails}" id="a">
<apex:selectOptions value="{!sparedetails}"/>
</apex:selectList>
</apex:pageblockSectionItem>
<apex:inputField value="{!sparedet.sparepartsinp__c}" rendered="{!check}"/>
<apex:inputField label="QTY" value="{!sparedet.qty__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
My Controller:
public with sharing class sparedetail {
public Spare_Details__c sparedet{get;set;}
public boolean check{get;set;}
public String selspare{get;set;}
public List<SelectOption> Spare{get;set;}
public List<SelectOption> sparedetail {get;set;}
public List<SelectOption> sparedetails{get;set;}
public Engineer_Checklist__c ec{get;set;}
public sparedetail(ApexPages.StandardController controller) {
check =false;
//sparedet = [select spareparts__c,aspareparts__c,sparepartsinp__c,qty__c from Spare_Details__c where id=:apexpages.currentpage().getparameters().get('id')];
ec=[select id,Engineer__r.name from Engineer_Checklist__c where id=:apexpages.currentpage().getparameters().get('id')];
Spare=Spares();
}
public PageReference addrow(){
//sparedet.add(new Spare_Details__c(service_sheet__c=ec.id));
return null;
}
public List<SelectOption> Spares() {
List<SelectOption> spd = new List<SelectOption>();
spd.add(new SelectOption('None','--- None ---'));
spd.add(new SelectOption('sd','Smoke Detector'));
spd.add(new SelectOption('hd','Heat Detector'));
spd.add(new SelectOption('msd','Multi Sensor Detector'));
spd.add(new SelectOption('bs','Base'));
spd.add(new SelectOption('ss','Smoke Sounder'));
spd.add(new SelectOption('hs','Heat Sounder'));
spd.add(new SelectOption('bc','Breakglass Callpoint'));
spd.add(new SelectOption('tk','Test Keys'));
spd.add(new SelectOption('rg','Replacement Glass'));
spd.add(new SelectOption('bc','Breakglass Cover'));
spd.add(new SelectOption('es','Electronic Sounder'));
spd.add(new SelectOption('fb','Fire Bell'));
spd.add(new SelectOption('bec','Beacon'));
spd.add(new SelectOption('dr','Door Release'));
spd.add(new SelectOption('pc','Printer Consumables'));
spd.add(new SelectOption('slab','SLA Battery'));
spd.add(new SelectOption('nic','Nicad Hi-Temp Cells X'));
spd.add(new SelectOption('anic','Additional Nicad Hi-Temp Cells X'));
spd.add(new SelectOption('el','Emergency Lights'));
spd.add(new SelectOption('ael','Additional Emergency Lights'));
spd.add(new SelectOption('elt','EL Tube'));
spd.add(new SelectOption('aelt','Additional EL Tube'));
spd.add(new SelectOption('ftt','4,6,8FT Tube'));
spd.add(new SelectOption('lbs','Log Book Supplied - Qty'));
spd.add(new SelectOption('oth','Other'));
return spd;
}
public List<SelectOption> sparedetails(){
List<SelectOption> spdl = new List<SelectOption>();
if(selspare == 'sd' || selspare == 'hd' || selspare == 'ss' || selspare == 'hs' || selspare == 'es' || selspare == 'bec'){
spdl.add(new SelectOption('at','ADT'));
spdl.add(new SelectOption('ad','Apollo Discovery'));
spdl.add(new SelectOption('as65','Apollo S65'));
spdl.add(new SelectOption('ax95','Apollo XP95'));
spdl.add(new SelectOption('aut','Autronica'));
spdl.add(new SelectOption('ed','EDA'));
spdl.add(new SelectOption('em','EMS'));
spdl.add(new SelectOption('get','Gent'));
spdl.add(new SelectOption('hoc','Hochiki'));
spdl.add(new SelectOption('nitt','Nittan'));
spdl.add(new SelectOption('not','Notifier'));
spdl.add(new SelectOption('men','Menvier'));
spdl.add(new SelectOption('pro','Protec'));
spdl.add(new SelectOption('raf','Rafiki'));
spdl.add(new SelectOption('sys','Systemsensor'));
spdl.add(new SelectOption('zit','Ziton'));
spdl.add(new SelectOption('oth','Other'));
}
if(selspare == 'msd'){
}
if(selspare == 'bs'){
spdl.add(new SelectOption('db','Detector Base'));
spdl.add(new SelectOption('dob','Diode Base'));
}
if(selspare == 'bc'){
spdl.add(new SelectOption('at','ADT'));
spdl.add(new SelectOption('ad','Apollo Discovery'));
spdl.add(new SelectOption('as65','Apollo S65'));
spdl.add(new SelectOption('ax95','Apollo XP95'));
spdl.add(new SelectOption('aut','Autronica'));
spdl.add(new SelectOption('ed','EDA'));
spdl.add(new SelectOption('em','EMS'));
spdl.add(new SelectOption('get','Gent'));
spdl.add(new SelectOption('hoc','Hochiki'));
spdl.add(new SelectOption('nitt','Nittan'));
spdl.add(new SelectOption('not','Notifier'));
spdl.add(new SelectOption('men','Menvier'));
spdl.add(new SelectOption('pro','Protec'));
spdl.add(new SelectOption('raf','Rafiki'));
spdl.add(new SelectOption('sys','Systemsensor'));
spdl.add(new SelectOption('zit','Ziton'));
spdl.add(new SelectOption('wp','Waterproof'));
spdl.add(new SelectOption('oth','Other'));
}
if(selspare == 'tk' || selspare == 'rg' || selspare == 'bc' || selspare == 'fb' || selspare == 'dr' || selspare == 'pc' || selspare == 'ftt' || selspare == 'lbs' || selspare == 'oth'){
check = true;
}
if(selspare == 'slab'){
spdl.add(new SelectOption('1.2a','12v 1.2Ah'));
spdl.add(new SelectOption('12a','12v 12Ah'));
spdl.add(new SelectOption('17a','12v 17Ah'));
spdl.add(new SelectOption('2.1a','12v 2.1Ah'));
spdl.add(new SelectOption('2.8a','12v 2.8Ah'));
spdl.add(new SelectOption('24a','12v 24Ah'));
spdl.add(new SelectOption('3.2a','12v 3.2Ah'));
spdl.add(new SelectOption('7a','12v 7Ah'));
spdl.add(new SelectOption('10a','6v 10Ah'));
spdl.add(new SelectOption('ed','EDA'));
spdl.add(new SelectOption('es','EMS'));
}
if(selspare == 'nic' || selspare == 'anic'){
spdl.add(new SelectOption('1c','1 Cell'));
spdl.add(new SelectOption('2c','2 Cell'));
spdl.add(new SelectOption('3c','3 Cell'));
spdl.add(new SelectOption('4c','4 Cell'));
spdl.add(new SelectOption('5c','5 Cell'));
spdl.add(new SelectOption('oth','Other'));
}
if(selspare == 'el' || selspare == 'ael'){
spdl.add(new SelectOption('16w','16w 2D'));
spdl.add(new SelectOption('28w','28w 2D'));
spdl.add(new SelectOption('38w','38w 2D'));
spdl.add(new SelectOption('2d','28w 2D c/w P/c'));
spdl.add(new SelectOption('8w','8w Bulkhead'));
spdl.add(new SelectOption('eb','Exit Box'));
spdl.add(new SelectOption('ld','LED'));
spdl.add(new SelectOption('ldb','LED Bulkhead'));
spdl.add(new SelectOption('leb','LED Exit box'));
spdl.add(new SelectOption('lgd','Legend'));
spdl.add(new SelectOption('tb','Twinspot Beam'));
}
if(selspare == 'elt' || selspare == 'aelt'){
spdl.add(new SelectOption('4w','4 Watt Tube rep.'));
spdl.add(new SelectOption('6w','6 Watt Tube rep.'));
spdl.add(new SelectOption('8w','8 Watt Tube rep.'));
spdl.add(new SelectOption('2d','2D Lamp/Biax'));
}
return spdl;
}
}
Hello I have to like create a dependency picklist in vf page. But my first picklist value has been displayed. But when i have to change first picklist the second picklist not changed and also not displayed. IF anyone know please let me.
<apex:page standardController="Engineer_Checklist__c" extensions="sparedetail">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="5" title="Spare Details">
<apex:pageblockSectionItem >
<apex:selectList size="1" multiselect="false" value="{!selspare}">
<apex:selectOptions value="{!Spare}"/>
<apex:actionSupport event="onchange" reRender="a"/>
</apex:selectList>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:selectList size="1" multiselect="false" value="{!sparedetails}" id="a">
<apex:selectOptions value="{!sparedetails}"/>
</apex:selectList>
</apex:pageblockSectionItem>
<apex:inputField value="{!sparedet.sparepartsinp__c}" rendered="{!check}"/>
<apex:inputField label="QTY" value="{!sparedet.qty__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
My Controller:
public with sharing class sparedetail {
public Spare_Details__c sparedet{get;set;}
public boolean check{get;set;}
public String selspare{get;set;}
public List<SelectOption> Spare{get;set;}
public List<SelectOption> sparedetail {get;set;}
public List<SelectOption> sparedetails{get;set;}
public Engineer_Checklist__c ec{get;set;}
public sparedetail(ApexPages.StandardController controller) {
check =false;
//sparedet = [select spareparts__c,aspareparts__c,sparepartsinp__c,qty__c from Spare_Details__c where id=:apexpages.currentpage().getparameters().get('id')];
ec=[select id,Engineer__r.name from Engineer_Checklist__c where id=:apexpages.currentpage().getparameters().get('id')];
Spare=Spares();
}
public PageReference addrow(){
//sparedet.add(new Spare_Details__c(service_sheet__c=ec.id));
return null;
}
public List<SelectOption> Spares() {
List<SelectOption> spd = new List<SelectOption>();
spd.add(new SelectOption('None','--- None ---'));
spd.add(new SelectOption('sd','Smoke Detector'));
spd.add(new SelectOption('hd','Heat Detector'));
spd.add(new SelectOption('msd','Multi Sensor Detector'));
spd.add(new SelectOption('bs','Base'));
spd.add(new SelectOption('ss','Smoke Sounder'));
spd.add(new SelectOption('hs','Heat Sounder'));
spd.add(new SelectOption('bc','Breakglass Callpoint'));
spd.add(new SelectOption('tk','Test Keys'));
spd.add(new SelectOption('rg','Replacement Glass'));
spd.add(new SelectOption('bc','Breakglass Cover'));
spd.add(new SelectOption('es','Electronic Sounder'));
spd.add(new SelectOption('fb','Fire Bell'));
spd.add(new SelectOption('bec','Beacon'));
spd.add(new SelectOption('dr','Door Release'));
spd.add(new SelectOption('pc','Printer Consumables'));
spd.add(new SelectOption('slab','SLA Battery'));
spd.add(new SelectOption('nic','Nicad Hi-Temp Cells X'));
spd.add(new SelectOption('anic','Additional Nicad Hi-Temp Cells X'));
spd.add(new SelectOption('el','Emergency Lights'));
spd.add(new SelectOption('ael','Additional Emergency Lights'));
spd.add(new SelectOption('elt','EL Tube'));
spd.add(new SelectOption('aelt','Additional EL Tube'));
spd.add(new SelectOption('ftt','4,6,8FT Tube'));
spd.add(new SelectOption('lbs','Log Book Supplied - Qty'));
spd.add(new SelectOption('oth','Other'));
return spd;
}
public List<SelectOption> sparedetails(){
List<SelectOption> spdl = new List<SelectOption>();
if(selspare == 'sd' || selspare == 'hd' || selspare == 'ss' || selspare == 'hs' || selspare == 'es' || selspare == 'bec'){
spdl.add(new SelectOption('at','ADT'));
spdl.add(new SelectOption('ad','Apollo Discovery'));
spdl.add(new SelectOption('as65','Apollo S65'));
spdl.add(new SelectOption('ax95','Apollo XP95'));
spdl.add(new SelectOption('aut','Autronica'));
spdl.add(new SelectOption('ed','EDA'));
spdl.add(new SelectOption('em','EMS'));
spdl.add(new SelectOption('get','Gent'));
spdl.add(new SelectOption('hoc','Hochiki'));
spdl.add(new SelectOption('nitt','Nittan'));
spdl.add(new SelectOption('not','Notifier'));
spdl.add(new SelectOption('men','Menvier'));
spdl.add(new SelectOption('pro','Protec'));
spdl.add(new SelectOption('raf','Rafiki'));
spdl.add(new SelectOption('sys','Systemsensor'));
spdl.add(new SelectOption('zit','Ziton'));
spdl.add(new SelectOption('oth','Other'));
}
if(selspare == 'msd'){
}
if(selspare == 'bs'){
spdl.add(new SelectOption('db','Detector Base'));
spdl.add(new SelectOption('dob','Diode Base'));
}
if(selspare == 'bc'){
spdl.add(new SelectOption('at','ADT'));
spdl.add(new SelectOption('ad','Apollo Discovery'));
spdl.add(new SelectOption('as65','Apollo S65'));
spdl.add(new SelectOption('ax95','Apollo XP95'));
spdl.add(new SelectOption('aut','Autronica'));
spdl.add(new SelectOption('ed','EDA'));
spdl.add(new SelectOption('em','EMS'));
spdl.add(new SelectOption('get','Gent'));
spdl.add(new SelectOption('hoc','Hochiki'));
spdl.add(new SelectOption('nitt','Nittan'));
spdl.add(new SelectOption('not','Notifier'));
spdl.add(new SelectOption('men','Menvier'));
spdl.add(new SelectOption('pro','Protec'));
spdl.add(new SelectOption('raf','Rafiki'));
spdl.add(new SelectOption('sys','Systemsensor'));
spdl.add(new SelectOption('zit','Ziton'));
spdl.add(new SelectOption('wp','Waterproof'));
spdl.add(new SelectOption('oth','Other'));
}
if(selspare == 'tk' || selspare == 'rg' || selspare == 'bc' || selspare == 'fb' || selspare == 'dr' || selspare == 'pc' || selspare == 'ftt' || selspare == 'lbs' || selspare == 'oth'){
check = true;
}
if(selspare == 'slab'){
spdl.add(new SelectOption('1.2a','12v 1.2Ah'));
spdl.add(new SelectOption('12a','12v 12Ah'));
spdl.add(new SelectOption('17a','12v 17Ah'));
spdl.add(new SelectOption('2.1a','12v 2.1Ah'));
spdl.add(new SelectOption('2.8a','12v 2.8Ah'));
spdl.add(new SelectOption('24a','12v 24Ah'));
spdl.add(new SelectOption('3.2a','12v 3.2Ah'));
spdl.add(new SelectOption('7a','12v 7Ah'));
spdl.add(new SelectOption('10a','6v 10Ah'));
spdl.add(new SelectOption('ed','EDA'));
spdl.add(new SelectOption('es','EMS'));
}
if(selspare == 'nic' || selspare == 'anic'){
spdl.add(new SelectOption('1c','1 Cell'));
spdl.add(new SelectOption('2c','2 Cell'));
spdl.add(new SelectOption('3c','3 Cell'));
spdl.add(new SelectOption('4c','4 Cell'));
spdl.add(new SelectOption('5c','5 Cell'));
spdl.add(new SelectOption('oth','Other'));
}
if(selspare == 'el' || selspare == 'ael'){
spdl.add(new SelectOption('16w','16w 2D'));
spdl.add(new SelectOption('28w','28w 2D'));
spdl.add(new SelectOption('38w','38w 2D'));
spdl.add(new SelectOption('2d','28w 2D c/w P/c'));
spdl.add(new SelectOption('8w','8w Bulkhead'));
spdl.add(new SelectOption('eb','Exit Box'));
spdl.add(new SelectOption('ld','LED'));
spdl.add(new SelectOption('ldb','LED Bulkhead'));
spdl.add(new SelectOption('leb','LED Exit box'));
spdl.add(new SelectOption('lgd','Legend'));
spdl.add(new SelectOption('tb','Twinspot Beam'));
}
if(selspare == 'elt' || selspare == 'aelt'){
spdl.add(new SelectOption('4w','4 Watt Tube rep.'));
spdl.add(new SelectOption('6w','6 Watt Tube rep.'));
spdl.add(new SelectOption('8w','8 Watt Tube rep.'));
spdl.add(new SelectOption('2d','2D Lamp/Biax'));
}
return spdl;
}
}
Hello I have to like create a dependency picklist in vf page. But my first picklist value has been displayed. But when i have to change first picklist the second picklist not changed and also not displayed. IF anyone know please let me.
Try below code and let me know if this helps you.
Best Regards,
-Vivek deshmane
Try to use following code.
Visualforce Page:
Apex Class:
Thank You,
Hitesh Patel
SFDC Certified Advanced Developer & Administrator
Email :- hiteshpatel.aspl@gmail.com