You need to sign in to do that
Don't have an account?
narsavagep
Lightning Web Component - Navigation - Use Case for Links in a List / Table
I need to create a link to an object within a data-table listing.
For example, list of contacts on a data table, when the user clicks the "name", it opens that Contact record view.
This seems simple enough, and yet, I'm having trouble finding a solution or example anywhere out on the internet or trailhead. It seems like all the solutions I find are using "tiles" and cascading events. I don't need anything that complicated.
I can post example/more information below... but would love it if someone could explain how to do this (using NavigationMixin)
In this example, they are not making the name a link -- I would like to make it a link that would open that contact's record view.
What would the "viewContact" js look like?
Something along the lines of:
I don't understand how to pass the contact.Id value from the HTML to the JS (?????)
Or, using:
(I realized the button isn't what I wanted)
In this example, in the past I would have just put "/{contact.Id}" -- but that doesn't work with the lightning web component : it gives me the error: Ambiguous attribute value value="/{c.Id}". If you want to make it a string you should escape it value="\/{c.Id}" -- and if I escape it using \/, then the link it forms is incorrect.
So, it seems the lightning-formatted-url element is for a link to a different site/page with a hard-coded value, not a dynamic one. You should be able to use an anchor tag:
or, more advanced, the lightning-navigation.