You need to sign in to do that
Don't have an account?

Bind data with the Repeat functionality form the controller to Visualforce page
//Data is getting append to the Html select tag, but not appending to the selectlist tag in saleforce.
Note: To use Repeat functionality only ..!
Visualforce page:
Apex class:
After inspecting: it was binded to the html tag but not salesforce tag..
thanks
Deepika..!
Note: To use Repeat functionality only ..!
Visualforce page:
<apex:page controller="test12" > <apex:form > Salesforce Selectlist: <apex:selectList multiselect="false" size="1"> <apex:selectOption ></apex:selectOption> <apex:repeat value="{!lstWrapper1}" var="a"> <apex:selectOption itemLabel="{!a.Statename}" itemvalue="{!a.rating}" html-data-capitalname="{!a.capital}"></apex:selectOption> </apex:repeat> </apex:selectList> <br/> <br/> Html Selectlist: <select> <apex:repeat value="{!lstWrapper1}" var="a"> <option value="{!a.rating}" data-capitalname="{!a.capital}">{!a.statename}</option> </apex:repeat> </select> </apex:form> </apex:page>
Apex class:
public class test12 { public string selectedOption{get;set;} public Wrapper Wrapper1{get;set;} public list<wrapper> lstWrapper1{get;set;} public test12(){ lstWrapper1 = new list<wrapper>(); string jsonexample1 = ' { "overalldata": [ {"stateName": "Andrapradesh", "rating": "5.0" , "active": "yes" ,"Capital":"Amaravathi"}, { "stateName": "Telangana", "rating": "4.0" ,"active": "no","Capital":"Hyderabad" }, {"stateName": "Karnataka", "rating": "5.0" ,"active": "no","Capital":"Banglore"} , {"stateName": "Maharastra", "rating": "4.5" ,"active": "no","Capital":"Mumbai"}] } '; Map<String, Object> mapobj1= (Map<String, Object>)JSON.deserializeUntyped(jsonexample1); system.debug('the Mapped and deserialized values are:'+ mapobj1); Object objj1 = (object)mapobj1.get('overalldata'); system.debug('the data value is :::'+objj1); string SerilizeEmpdata1 = system.json.serialize(objj1); system.debug(SerilizeEmpdata1); lstWrapper1 =(list<wrapper>)system.json.deserialize(SerilizeEmpdata1,list<wrapper>.class); system.debug(lstWrapper1); } public class Wrapper{ public string stateName{get;set;} public string rating{get;set;} public string active{get;set;} public string Capital{get;set;} } }
After inspecting: it was binded to the html tag but not salesforce tag..
thanks
Deepika..!
You need to use <apex:selectOptions> instead of <apex:selectOption> and it will work for you. Please see the below link for its usage.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_selectOptions.htm
Thanks
Note: selectoptions is not accepting the parameter as the Data-attribute in salesforce..!
Thank you..!
Deepika