Hi everybody I am coding a LWC datatable with several columns and the last one is a column with buttons. the columns are the next one:
const COLUMNS = [
{
label: 'Punto de producción',
fieldName: 'name',
type: 'lookup',
iconName: 'utility:checkin',
initialWidth: 330,
editable: false,
},
{
label: 'Distancia (km)',
fieldName: 'distance',
type: 'Text',
iconName:'utility:product_transfer',
initialWidth: 230,
editable:false
},
{
label: 'Número de solicitudes',
fieldName: 'requestsNumbers',
type: 'Text',
iconName: 'utility:work_order_type',
initialWidth: 200,
editable: false,
},
{
label: 'Acciones',
type: "button",
iconName: 'utility:touch_action',
typeAttributes:{
label: 'Asignar',
name: 'Asignar',
title: 'Asignar',
disabled: false,
iconPosition: 'center',
value: 'Asignar',
},
}
]
Using javascript I want to get the json from the button column to modify them. So I have the function:
actionFromButton(event){
const valueButton = event.detail.action.value;
}
What I need is that the blue button Add to turn red when clicked and change its name to Remove and vice versa.
What I was wondering is if there is a way to get all the attributes from the button to modify them because I want to change the name and value and change it in the LWC. And I want to know if this can be done, I mean be able to modify the attributes.
I am struggling with this. Could anybody help me?
Thanks