You need to sign in to do that
Don't have an account?
VenkataRamanjaneyulu Kattamuru
Hi all,
when i was trying to remove theoptions which selected I am unable to do anything(even logs are not coming in that method).
Please help ,
My code is shown below:
Apex-Class::
public class RealTimeSoql {
public List<SelectOption> dropdowns {set;get;}
public List<String> selectedoptions {set;get;}
public Set<selectOption> displayList {set;get;}
public List<string> removeList {set;get;}
public RealTimeSoql(){
dropdowns = new List<SelectOption>();
selectedoptions = new List<String>();
displayList = new Set<selectOption>();
removeList = new List<string>();
List<String> fields = new List<String>{'Name','Phone','Industry','Rating'};
for(String s: fields){
Selectoption sop = new SelectOption(s,s);
dropdowns.add(sop);
}
}
public void addOptions(){
for(String s:selectedoptions){
Selectoption dop = new SelectOption(s,s);
displayList.add(dop);
}
}
public void removeOptions(){
System.debug('removeList:=============>'+ removeList);
for(string s:removeList){
Integer indexOfstring = selectedoptions.indexOf(s);
String removed = selectedoptions.remove(indexOfstring);
}
System.debug('selectedoptions after remove:=============>'+ selectedoptions);
addOptions();
}
}
********************************************************************************************************
VFPage:
<apex:page controller="RealTimeSoql">
<apex:form >
<style>
.box{
width : 200px;
height: 100px;
}
</style>
<apex:pageBlock >
<apex:selectList value="{!selectedoptions}" multiselect="true" styleClass="box">
<apex:selectOptions value="{!dropdowns}"/>
</apex:selectList>
<apex:commandButton value="add" action="{!addOptions}"/>
<apex:commandButton value="remove" action="{!removeOptions}"/>
<apex:selectList multiselect="true" styleClass="box" value="{!removeList}" >
<apex:selectOptions value="{!displayList}"/>
</apex:selectList>
</apex:pageBlock>
</apex:form>
</apex:page>
when i was trying remove the options selected I am unable to do anything & i am not getting any exception too..Please help.
Hi all,
when i was trying to remove theoptions which selected I am unable to do anything(even logs are not coming in that method).
Please help ,
My code is shown below:
Apex-Class::
public class RealTimeSoql {
public List<SelectOption> dropdowns {set;get;}
public List<String> selectedoptions {set;get;}
public Set<selectOption> displayList {set;get;}
public List<string> removeList {set;get;}
public RealTimeSoql(){
dropdowns = new List<SelectOption>();
selectedoptions = new List<String>();
displayList = new Set<selectOption>();
removeList = new List<string>();
List<String> fields = new List<String>{'Name','Phone','Industry','Rating'};
for(String s: fields){
Selectoption sop = new SelectOption(s,s);
dropdowns.add(sop);
}
}
public void addOptions(){
for(String s:selectedoptions){
Selectoption dop = new SelectOption(s,s);
displayList.add(dop);
}
}
public void removeOptions(){
System.debug('removeList:=============>'+ removeList);
for(string s:removeList){
Integer indexOfstring = selectedoptions.indexOf(s);
String removed = selectedoptions.remove(indexOfstring);
}
System.debug('selectedoptions after remove:=============>'+ selectedoptions);
addOptions();
}
}
********************************************************************************************************
VFPage:
<apex:page controller="RealTimeSoql">
<apex:form >
<style>
.box{
width : 200px;
height: 100px;
}
</style>
<apex:pageBlock >
<apex:selectList value="{!selectedoptions}" multiselect="true" styleClass="box">
<apex:selectOptions value="{!dropdowns}"/>
</apex:selectList>
<apex:commandButton value="add" action="{!addOptions}"/>
<apex:commandButton value="remove" action="{!removeOptions}"/>
<apex:selectList multiselect="true" styleClass="box" value="{!removeList}" >
<apex:selectOptions value="{!displayList}"/>
</apex:selectList>
</apex:pageBlock>
</apex:form>
</apex:page>
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Visualforce:
Controller:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
All Answers
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Visualforce:
Controller:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas