function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PGKPGK 

lightning datatable in LWC

I have a requirement in lightning datatable, if I click on one column values (hyperlink) it should call another LWC component.
 
For example, consider there are many rows and 5 columns (A,B,C,D,E) in lightning datatable and D column type is hyperlink and other column type is text. Now if I click on column D (hyperlink) it should call another LWC component. Could someone guide me on this?
ravi soniravi soni

Hi PGK,
lwc component that you are going to call, is it a child component? if it is a child component, simply you can directly call the child cmp method by querySelector like below.

this.template.querySelector('c-child-cmp-name').methodName();
but before write above line first you need to create a method in your child cmp and method  should be @api such as below.

@api methodName(){

}
after that you can call this.template.querySelector('c-child-cmp-name').methodName(); this line from parent cmp.

forExample : 
onHandleClick(event){
event.preventDefault();
this.template.querySelector('c-child-cmp-name').methodName();
}

 

and if you have a separate cmp, you can call by LMS.

https://developer.salesforce.com/docs/component-library/bundle/lightning-message-service/documentation
let me know about your status. this answer is helpful to you or not. If yes mark it as the best answer.
Thank you
 



 

PriyaPriya (Salesforce Developers) 

Hey PGK,

You can refer this link :- 

https://salesforce.stackexchange.com/questions/275487/how-to-create-a-link-in-lwc-which-will-open-another-lwc

If it helps you can mark it as the best answer.

Thanks,

Priya Ranjan

mukesh guptamukesh gupta
HI PKG,

Below url will help for your solution:-

https://salesforce.stackexchange.com/questions/299066/call-child-lwc-from-parent-lwc-through-button

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh