Skip to main content

Hi All,

 

Can anyone please help me here,

 

Onclick of the below <lightning:input/>(checkbox), I need to display a <lightning:select>(picklist values) which is coming from apex class as Map type. I am able to get the Map in js controller but the values are not coming inside "<option>{!r}</option>" . Can anyone please reply me how to iterate Map in lightning and fix the problem in the code below.

 

<aura:component controller="ManualClass">

    <aura:attribute name="recType" type="Map"/>

   <aura:attribute name="cRlsVal" type="Boolean"/>

    <lightning:input aura:id="cRlsCheck" type="checkbox" name="checkBox"

                             label="Add this step to In-Progress releases?" onchange="{!c.cRlsCheckBox}"/>

   <aura:if isTrue="{!v.cRlsVal}">

      <lightning:select name="selectItem" label="Select Record Type">

          <aura:iteration items="{!v.recType}" var="r">

              <option>{!r}</option>

          </aura:iteration>

     </lightning:select>

  </aura:if>

</aura:component>

 

({ 

cRlsCheckBox : function(component, event, helper){

        component.set("v.cRlsVal",component.find("cRlsCheck").get("v.checked"));

        var action = component.get("c.fetchRecType");

        action.setCallback(this,function(response){

            if(response.getState() == "SUCCESS"){

                component.set("v.recType",response.getReturnValue());

                alert("Success"+JSON.stringify(response.getReturnValue()));

            }

        });

        $A.enqueueAction(action);

    }

})

 

@AuraEnabled 

    public static  Map<String, String> fetchRecType(){

            Map<String, String> recTypeMap = DeploymentControllerService.getRecordTypeByObjectName(Label.Manual_Steps);

            return recTypeMap;      

    }

0/9000