I want to redirect from child object (Primary_Terms__c) to parent record detail object(Acquisition_Deal) page using lightining component code
my apex class:
public class acquisitiondeallightningcntrl
{
@AuraEnabled
public static list<Primary_Terms__c> getdealid(){
return[SELECT Id,Acquisition_Deal__c FROM Primary_Terms__c];
}}
Lightining component:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" controller="acquisitiondeallightningcntrl">
<aura:attribute name="deal" type="Acquisition_Deal__c[]"/>
<aura:registerEvent name="navEvt" type="force:navigateToSObject"/>
<aura:handler event="force:navigateToSObject" action="{!c.navigate}"/>
<aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
<table class="slds-p-around_x-small slds-text-body_small slds-table slds-table--bordered slds-table--fixed-layout " >
<thead>
</thead>
<tbody>
<aura:iteration items="{!v.deal}" var="e">
<tr class="slds-hint-parent" >
<td><lightning:button variant="brand" label="Acquisition Deal" onclick="{!c.navigate}" />
</td>
<td scope="row">
<div class="slds-truncate slds-text-align--right" >
<a target="_blank" href="{!'/'+e.Id}">{!e.Name}</a>
</div>
</td>
</tr>
</aura:iteration>
</tbody>
</table>
</aura:component>
Controller:
({
doInit: function(component, event, helper) {
var action = component.get("c.getdealid");
action.setCallback(this, function(response) {
var state = response.getState();
if (component.isValid() && state === "SUCCESS") {
component.set("v.deal", response.getReturnValue());
}
else {
console.log("Failed with state: " + state);
}
});
// Send action off to be executed
$A.enqueueAction(action);
},
navigate:function(component){
var idx= event.currentTarget.id;
var navEvt = $A.get("e.force:navigateToSObject");
navEvt.setParams({
"recordId": idx,
"slideDevName": "detail"
});
navEvt.fire();
}
})
I am Getting Error:
Uncaught Action failed: c:Redirectingthepage$controller$navigate [Cannot read property 'current Target' of undefined]
please anyone help me to resolve this error and also for redirecting the parent page