You need to sign in to do that
Don't have an account?
Vignesh Ramshetty
I have code please give me a alert on onclick on approval button and reject button and URL
<aura:component controller="Approval_Process_Details" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="records" type="Object[]" />
<aura:attribute name="columns" type="List"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<lightning:card title="Approval Card" iconName="standard:approval">
<lightning:datatable
keyField="Id"
data="{!v.records}"
columns="{!v.columns}"
hideCheckboxColumn="true"
onrowselection="{!c.handleRowSelection}"
showRowNumberColumn="true"
/>
</lightning:card>
</aura:component>
Controller.js:
({
doInit: function(component, event, helper) {
helper.fetchData(component, event, helper);
},
handleRowSelection: function(component, event, helper) {
alert('Hi')
}
})
helper:
({
fetchData: function(component, event, helper) {
var action = component.get("c.Approval_Process_Details_Method");
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var records = response.getReturnValue();
var tempRecs = [];
component.set("v.records", records);
component.set("v.columns", [
{ label: 'Opportunity Name', fieldName: 'Opp_Id', type: 'url',
typeAttributes: { label: { fieldName: 'Opp_Name' }, target: '_self ', onclick: 'navigateToRecordPage'}
},
{ label: "Comment", fieldName: "Claim_Comment", type: "text" },
{ label: "Close Date", fieldName: "Opp_CLose_Won", type: "text" },
{ label: "Date Of Approvel Applied", fieldName: "User_Applied_Date", type: "text" },
{ label: "Owner Name", fieldName: "Opp_Owner_Name", type: "text" },
{ label: "Name Of User Who Submitted", fieldName: "User_Who_Submitted", type: "text" },
{
type: "button",
typeAttributes: {
label: "Approve",
name: "approve",
title: "Approve",
value: "Id"
},
onclick: component.getReference("c.handleApprove")
},
{
type: "button",
typeAttributes: {
label: "Reject",
name: "reject",
title: "Reject",
value: "Id"
}
}
]);
}
});
$A.enqueueAction(action);
},
})
<aura:attribute name="records" type="Object[]" />
<aura:attribute name="columns" type="List"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<lightning:card title="Approval Card" iconName="standard:approval">
<lightning:datatable
keyField="Id"
data="{!v.records}"
columns="{!v.columns}"
hideCheckboxColumn="true"
onrowselection="{!c.handleRowSelection}"
showRowNumberColumn="true"
/>
</lightning:card>
</aura:component>
Controller.js:
({
doInit: function(component, event, helper) {
helper.fetchData(component, event, helper);
},
handleRowSelection: function(component, event, helper) {
alert('Hi')
}
})
helper:
({
fetchData: function(component, event, helper) {
var action = component.get("c.Approval_Process_Details_Method");
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var records = response.getReturnValue();
var tempRecs = [];
component.set("v.records", records);
component.set("v.columns", [
{ label: 'Opportunity Name', fieldName: 'Opp_Id', type: 'url',
typeAttributes: { label: { fieldName: 'Opp_Name' }, target: '_self ', onclick: 'navigateToRecordPage'}
},
{ label: "Comment", fieldName: "Claim_Comment", type: "text" },
{ label: "Close Date", fieldName: "Opp_CLose_Won", type: "text" },
{ label: "Date Of Approvel Applied", fieldName: "User_Applied_Date", type: "text" },
{ label: "Owner Name", fieldName: "Opp_Owner_Name", type: "text" },
{ label: "Name Of User Who Submitted", fieldName: "User_Who_Submitted", type: "text" },
{
type: "button",
typeAttributes: {
label: "Approve",
name: "approve",
title: "Approve",
value: "Id"
},
onclick: component.getReference("c.handleApprove")
},
{
type: "button",
typeAttributes: {
label: "Reject",
name: "reject",
title: "Reject",
value: "Id"
}
}
]);
}
});
$A.enqueueAction(action);
},
})