I want to call a javascript function from the icon in the first column. I had it working with the checkbox that comes out of the box but a checkbox doesn't make sense for an edit function. In my saColumns definition, I added the first column and want it to call the js function below
js:
const saColumns = [
{
type: 'button-icon',
fixedWidth: 40,
typeAttributes: {
iconName: 'utility:edit',
name: 'edit_record',
title: 'Edit',
variant: 'bare',
alternativeText: 'edit',
disabled: false
}
},
{label: 'Title', fieldName: 'Title__c', type: 'pickList'},
{label: 'User', fieldName: 'UserName', Id: 'User__c',type: 'text'}
];
handleRowSelection(event) {
//alert('1');
const selectedRows = event.detail.selectedRows;
this.selectedSAIds = [];
this.showTable = false;
for (let i = 0; i < selectedRows.length; i++) {
this.selectedSAIds.push(selectedRows[i].Id);
}
}
html:
<template if:true={hasSAs}>
<lightning-datatable
data={datatableSAs}
columns={saColumns}
key-field="Id"
onrowselection={handleRowSelection}
hide-checkbox-column="true"
selected-rows={selectedSAIds}>
</lightning-datatable>
</template>
I have not been able to find a way to call the handleRowSelection. Any direction would be appreciated!