From the ligtning:datatable documentation, a helper function can be called from the controller that adds the relevant row-level actions. Copied here...
Controller:
init: function (cmp, event, helper) {
var actions = helper.getRowActions.bind(this, cmp);
cmp.set('v.mycolumns', [
// Other column data here
{ label: 'State', fieldName: 'active', type: 'text' },
{ type: 'action', typeAttributes: { rowActions: actions } }
]);
// Fetch or set your data
},
Helper:
getRowActions: function (cmp, row, doneCallback) {
var actions = [];
if (row['isActive']) {
actions.push({
'label': 'Deactivate',
'iconName': 'utility:block_visitor',
'name': 'deactivate'
});
} else {
actions.push({
'label': 'Activate',
'iconName': 'utility:adduser',
'name': 'activate'
});
}
// simulate a trip to the server
setTimeout($A.getCallback(function () {
doneCallback(actions);
}), 200);
},
I'd like to reference some other helper functions from within the getRowActions
helper function but the example doesn't pass the helper in and also this
that would normally resolve to the helper is undefined.
Is there a solution?