• niranjan e
  • NEWBIE
  • 25 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies
//component 
<aura:attribute name="Companys" type="Object[]"></aura:attribute>
 <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<ui:inputSelect label="Proviences" class="dynamic" aura:id="InputSelectDynamic" value="{!v.Companys}" change="{!c.onSelectChange}"> required="False">
      <aura:iteration items="{!v.Companys}" var="levels">
          <ui:inputSelectOption text="{!levels.value}" label="{!levels.label}"/>
        </aura:iteration>
//controller 
doInit : function(component, event, helper) {
        var action = component.get("c.getLeadStatus");
        var inputsel = component.find("InputSelectDynamic");
        var opts=[];
        action.setCallback(this, function(a) {
        for(var i=0;i< a.getReturnValue().length;i++){
            opts.push({"class": "optionClass", label: a.getReturnValue()[i], value: a.getReturnValue()[i]});
        }
        inputsel.set("v.Companys", opts);
        component.set("v.Companys",opts);
         });
    $A.enqueueAction(action); 
    },
onSelectChange : function(component, event, helper) {
    var selected = component.find("InputSelectDynamic").get("v.Companys");
         alert('tt'+ selected); /// here i get ttundefined 
     }
//Serverside controller 
 @AuraEnabled
public static List<String> getLeadStatus(){
List<String> options = new List<String>();
Schema.DescribeFieldResult fieldResult = company__c.Province__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for (Schema.PicklistEntry f: ple) {
    options.add(f.getLabel());
}
system.debug('asdf'+options);
return options;}