You need to sign in to do that
Don't have an account?
Visualforce drop down list
Hi,
I am new to Salesforce.
Can anyone please help.
Below is my VF code:
<apex:repeat value="{!InnerList}" var="in"> <apex:selectList value="{!in.selectedValue1}" multiselect="false" style="width:200px;" size="1"> <apex:selectOptions value="{!Header}"/> </apex:selectList> <apex:selectList value="{!in.selectedValue2}" multiselect="false" style="width:200px;" size="1"> <apex:selectOptions value="{!FieldList}"/> </apex:selectList> </apex:repeat>
Controller:
public class communityCon1234 { public list<communityCon1Inner> Innerlist{get;set;} public class communityCon1Inner { public string selectedValue1{get;set;} public String selectedValue2{set;get;} } public communityCon1234() { InnerList = new list<communityCon1Inner>(); communityCon1Inner c= new communityCon1Inner(); InnerList.add(c); } }
And FieldList and Header contains values of drop down.
Suppose Header contains values like:
Name
Student
Year
College
DOJ
Using the above code i get the first value as default value i.e. Name in all the listboxes.
I want my listboxes to have Name in the first listbox,Student in the second listbox,year in the third listbox and so on.
I cannot use :
<apex:selectOptions value="{!Header[in]}"/>
As var="in" is of type innerlist of a inner class
I cannot remove the inner class as well because it is getting me the values of selectedvalue1 and selectedvalue2.
So please help.
Do i use an another repeat tag with var or what?
Thanks.
Just try this...
public class communityCon1Inner
{
public string selectedValue1{get;set;}
public String selectedValue2{set;get;}
public communityCon1Inner()
{
selectedValue1='Name';
selectedValue2='Student';
}
}
All Answers
You just need to take care of the assignment of the Selected value from your controller[ while you are generating/populating the wrappers]
So
If you want Name for the first Selectlis, assingn SelectedValue = 'Name' for it
Similarly for second
Thanks for the reply.
No i cant use it like
in.selectedValue = 'Name'
As the values for the drop down listbox are coming dynamically from a Excel file.
Should i send you my entire code on some personal id?
If you could help would be grateful.
Hi,
I guess SelectedValue2 is getting set to 'Name'.
Can you please check the Value in your WrapperList...
Thanks for the reply.
Yes neha,correct.
But i have a select list within repeat tag.
and for every select list i have the 'Name' value by default.
n i want each of my select list should have a different default value.
Like Name for first select list
Student for second and so on.
And in my case:
If you see the code i cannot use
Header[in] as return type of 'in' is not Number(Integer)
So how do i do it.
Please help.
Hi,
Here's an example for you that shows simple custom picklist implmention in visualforce.
Example for both select option and select options.
http://cloudforce4u.blogspot.in/2013/06/how-to-implement-custom-picklist-in.html
May be this could help you out.
Hit kudos adn mark this as answer if it helps you out.
thanks,
Just try this...
public class communityCon1Inner
{
public string selectedValue1{get;set;}
public String selectedValue2{set;get;}
public communityCon1Inner()
{
selectedValue1='Name';
selectedValue2='Student';
}
}