I'm using lightning:datatable
as such:
<aura:attribute name="resources" type="Object"/>
<aura:attribute name="mycolumns" type="List"/>
<aura:handler name="init" value="{! this }" action="{! c.doInit }"/>
<lightning:datatable data="{! v.resources }"
columns="{! v.mycolumns }"
keyField="Id"
onrowaction="{! c.javascriptClickGoesHere}" // Is this what I need to do?
hideCheckboxColumn="true"
/>
where I have set a button for each row:
{type: "button", typeAttributes: {
iconName: 'utility:add',
label: '',
name: 'selectRecord',
title: 'selectTitle',
disabled: false,
value: 'test',
I need to somehow use an onclick on each button (as I'm interested in getting the record ID for the button on the row clicked)
With regular lightning:button
, I'd have something like onclick="{!c.onClick}"
and in the controller
onClick: function(component, event, helper) {
var resource = component.get("v.resource");
var event = component.getEvent("ResourceSelected");
event.setParams({
resourceId: resource.Id,
});
event.fire();
},
How can I achieve the same effect with the button in datatables? onrowaction?