You need to sign in to do that
Don't have an account?
Agnibha Chakrabarti 10
how to call an onclick method when click on a data in lightning data table LWC
Hi, i have created following data table
column of data table are
Thanks
column of data table are
const columns = [ { label: 'Label', fieldName: 'name', type:'url',typeAttributes: {label: { fieldName: 'name' }, target: '_blank'}, wrapText: true }, { label: 'Website', fieldName: 'website', type: 'url' }, { label: 'Phone', fieldName: 'phone', type: 'phone' }, { label: 'Balance', fieldName: 'amount', type: 'currency' }, { label: 'CloseAt', fieldName: 'closeAt', type: 'date' }, ];My requirement is............ When i'll click on the name......it will do some Onclick action
Thanks
You can use onrowaction for function calling as like onclick.
below have the example . Please mark it as best answer if it helps you to fix the issue.
Thank you!
Regards,
Suraj Tripathi.
If you are having these kind of requirements, then you can use onrowaction in the lightning datatable.
for example,
Also, in the Table header you have to add the clickable element such as button; if in case you don't want to display button in the table just the text, then you can have button with the base variant.
for example,
onrowaction : viewRecord, you can have you row details using event.detail.row whenever button will be clicked.
This will cover your requirement. Hope this help you out.
Please mark it as best answer if it helps you to fix the issue.