1

I am using lightningmenu item in an aura iteration

event.detail.menuItem.get("v.value");

Compoennt Code

 <lightning:buttonMenu iconName="utility:down" onselect="{!c.onButtonMenuSelect}" alternativeText="Show menu" class="{!financialAccountRecord.Id}">
                        <lightning:menuItem value="edit" label="Edit"/>

Controller Code:

   onButtonMenuSelect: function(component, event, helper) {
    var idx = event.detail.menuItem("value"));
    switch (event.getParam("value")){
        case "edit": helper.doEdit(); break;
        case "delete": helper.doDelete(); break;
    }
}

Howvere the value of idx is coming as undefined. I also tried the following variations:

({
  handleSelect: function(component, event, helper) {
    switch event.get("value") {
      case "edit": helper.doEdit(); break;
      case "edit": helper.doDelete(); break;
    }
  }
})

1 Answer 1

0

First use event.getSource() to get the menu component, then .get("v.value") to get the current menu item that was selected.

Try this for the controller code:

onButtonMenuSelect: function(component, event, helper) {
    switch (event.getSource().get("v.value")){
        case "edit": helper.doEdit(); break;
        case "delete": helper.doDelete(); break;
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .