0

I want to redirect to another page on double click of row in lightning-datatable, i have tried to add double click listener to lightning-datatable but it does not work. Could you please provide any idea or sample code for this.

Thanks!

2 Answers 2

1

There's no way to add extra handlers to a Lightning component that doesn't support them. The standard LWC way of doing something would be to add an actions column (or a button column if you only need one button), and then handle the rowaction event to perform the requested action. Examples are included in the documentation.

1

You cannot achieve this with standard data types. However you can create a new data type by using custom LWC component and add double click behaviour in it. You can refer to How to use custom LWC lightning component in lightning-datatable for a simple example.

2
  • That would only add the functionality to a single cell, not the entire row, but this may work for the OP's purpose. My only caution is that this is outside of the standard Salesforce behavior and (probably) shouldn't be recommended.
    – sfdcfox
    Commented Jun 2, 2020 at 15:41
  • I have seen often that when somebody says "row", what they mean is a single "cell". Ofcourse it would not be recommended for whole row. @sfdcfox Commented Jun 2, 2020 at 16:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .