0

//Table with recordsetvar

<td data-label="EDIT AND DELETE">
   <lightning:buttonMenu alternativeText="More options"  onselect="{!c.editDeleteJS}" iconSize="small" aura:id="{!grpsegrel.Id}">
     <lightning:menuItem label="Edit"  value="editGrp" iconName="utility:edit"  />
     <lightning:menuItem label="Delete" value="deleteGrp"iconName="utility:delete" /> 
   </lightning:buttonMenu>
 </td>

//JSController Method

editDeleteJS: function(component, event, helper) {
    var menuValue = event.detail.menuItem.get("v.value");
    switch(menuValue) {
        case "editGrp": helper.doEdit(); break;
        case "deleteGrp": helper.doDelete(); break;
    }
}

//Helper

 doEdit: function(component, event, helper) {

    var editRecordEvent = $A.get("e.force:editRecord");
    var a = editRecordEvent.getSource();
    var idb = a.getLocalId();
    alert(idb);
    editRecordEvent.setParams({
        //"recordId": event.target.id
        "recordId": idb
    });
    editRecordEvent.fire();

}

From helper I am trying to capture that id, but either event.target or .getsource() are not returning the id any idea what i am doing wrong?

1
<lightning:buttonMenu alternativeText="More options"  onselect="{!c.editDeleteGRP}" iconSize="small" class = "{!grpsegrel.Id}"/>

Added Class in the the button menu and in controller retrieved using this line of code:

var tempid = event.getSource().get("v.class");

| improve this answer | |
0

Documentation says this.

editRecord : function(component, event, helper) {
    var editRecordEvent = $A.get("e.force:editRecord");
    editRecordEvent.setParams({
         "recordId": component.get("v.contact.Id")
   });
    editRecordEvent.fire();
} 

You need to implement force:hasRecordId then you will get the record id automatically from the context variable. Or You need to set an <aura:attribute> of object type and get the Id like v.contact.Id. Hope this helps

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.