You need to sign in to do that
Don't have an account?
Deepikareddy
How to append data form the Controller to Selectlist using the REPEAT TAG
APEXCLASS:
i have got the class and derserilized to the respective Class, now need to append the data to the picklist using the Selectlist using the Repeat Functionality...!
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;} } }
Need to Append the data using the Repeat functionality to selectoption in salesforce
<apex:page controller="test12" > <apex:form > <apex:selectList multiselect="false" size="1"> <apex:repeat value="{!lstWrapper1}" var="a" > <!--showing an error while appending to the select option---> </apex:repeat> </apex:selectList> </apex:form> </apex:page>
Note:
<apex:selectoption itemlabel ="{!lstwrapper.name}" and itemvalue= "{!lstwrapper.rating}" html-data-capitalname ="{!lstwrapper.capitalname}" />
//how it can be acheived....
Thanks
Deepika Reddy...
Try this eg,
http://www.infallibletechie.com/2014/04/difference-between-apexselectoption-and.html
If we are sure about the values, we can make use of apex:selectOption and If we are unsure about the values, we can make use of apex:selectOptions and we can fetch the values from our controller.
Use apex:selectOptions insted of repeat apex:selectOption
Try this eg:
Hope this helps..
1) I need to bind the data-attribute to selectoption tag .
//the data is binding to the html code, but it is unable to bind to the Salesforce Selectlist, ..! as shown in the image
//data is getting append to the html select tag, but not appending to the Salesforceselectlist