3

I'd like to have my datatable links open in a new sub tab when my users are using console navigation, but somehow they always open in a new tab.

Here's the column definition for the link field:

  { label: 'Name', fieldName: 'Link', type: 'url', 
typeAttributes: {label: { fieldName: 'Name'}, target: '_blank'}},

I considered using the WorkspaceAPI component:, but I don't see how I can catch the click event before the tab opens.

Does anyone have any ideas?

2
  • can you post code how currently open the tab? r u using oppenSubtab or openTab?
    – sdandamud1
    Commented Jun 26, 2019 at 18:15
  • @sdandamud1 I'm not using any code -it's a built in lightning-datatable column type. I'll add it.
    – hgolov
    Commented Jun 26, 2019 at 18:22

1 Answer 1

6

You can use the target attribute inside typeAttributes , as part of the column definition for your data table. Here's an example of hyperlinking the Case Number column in a Case data table:

{
    label: 'Case Number', 
    fieldName: 'URL',
    type: 'url', 
    typeAttributes: { 
        label: {
            fieldName: 'CaseNumber'
        },
        target: '_self'
    },
    sortable: true 
}

Using _self as the target opens a new console tab when used in the context of a Console application. The default behavior opens a new browser tab.

3
  • 1
    Perfect, thanks! Is this documented anywhere?
    – hgolov
    Commented Jun 26, 2019 at 18:56
  • 1
    Not that I know of. I just figured it out by experiment, I'm afraid.
    – David Reed
    Commented Jun 26, 2019 at 18:56
  • 3
    @DavidReed thanks for your inputs. in the context of a console app: don't know if the behavior has changed since your answer, but when using "_self", a new browser tab opened and then the page displays as a console tab in the new browser page. to workaround this I've used "_parent" instead, which then works fine and opens the page directly in a console tab of current page
    – Shamina
    Commented Jul 16, 2019 at 10:40

You must log in to answer this question.

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