Insert a link in lightning datatable Column Value

Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
I am trying to insert a link in a result column of lightning:datatable
Below is the code snippet :
Datatable Code:
<lightning:datatable data="! v.contactList "
columns="! v.mycolumns "
keyField="id"
onrowselection = "!c.checkboxFetch"
hideCheckboxColumn="false"
onrowaction="!c.checkboxFetch"
class="tableCss"
tabindex="1"/>
Controller Code:
label: 'Customer Name', fieldName: 'CustomerName__c', type: 'url',
sortable:"false",
typeAttributes:
label: 'Customer Name',
fieldName: 'CustomerName__c',
title: 'View',
disabled: false,
value: 'view',
iconPosition: 'left',
url: 'www.google.com',
, ,
However, in the result I am not able to link the column with the mentioned url and when clicking on the hyperlink it is redirecting to a localhost url like 172.9.0.1 (something like this)
Any idea on how to redirect to the url : www.google.com ? Also, the
customer result from the variable iteration
component.set('v.mycolumns'is not displaying the result.
Rather it displaying the static value : Customer Name
lightning lightning-experience slds datatable lightning-datatable
add a comment |Â
up vote
1
down vote
favorite
I am trying to insert a link in a result column of lightning:datatable
Below is the code snippet :
Datatable Code:
<lightning:datatable data="! v.contactList "
columns="! v.mycolumns "
keyField="id"
onrowselection = "!c.checkboxFetch"
hideCheckboxColumn="false"
onrowaction="!c.checkboxFetch"
class="tableCss"
tabindex="1"/>
Controller Code:
label: 'Customer Name', fieldName: 'CustomerName__c', type: 'url',
sortable:"false",
typeAttributes:
label: 'Customer Name',
fieldName: 'CustomerName__c',
title: 'View',
disabled: false,
value: 'view',
iconPosition: 'left',
url: 'www.google.com',
, ,
However, in the result I am not able to link the column with the mentioned url and when clicking on the hyperlink it is redirecting to a localhost url like 172.9.0.1 (something like this)
Any idea on how to redirect to the url : www.google.com ? Also, the
customer result from the variable iteration
component.set('v.mycolumns'is not displaying the result.
Rather it displaying the static value : Customer Name
lightning lightning-experience slds datatable lightning-datatable
You have to set the columntypeasurland in in data, you have to separately define the link you want the users to redirect to. Have a look at this example provided in the documentation, developer.salesforce.com/docs/component-library/bundle/â¦
â Ranga
Sep 16 at 11:43
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am trying to insert a link in a result column of lightning:datatable
Below is the code snippet :
Datatable Code:
<lightning:datatable data="! v.contactList "
columns="! v.mycolumns "
keyField="id"
onrowselection = "!c.checkboxFetch"
hideCheckboxColumn="false"
onrowaction="!c.checkboxFetch"
class="tableCss"
tabindex="1"/>
Controller Code:
label: 'Customer Name', fieldName: 'CustomerName__c', type: 'url',
sortable:"false",
typeAttributes:
label: 'Customer Name',
fieldName: 'CustomerName__c',
title: 'View',
disabled: false,
value: 'view',
iconPosition: 'left',
url: 'www.google.com',
, ,
However, in the result I am not able to link the column with the mentioned url and when clicking on the hyperlink it is redirecting to a localhost url like 172.9.0.1 (something like this)
Any idea on how to redirect to the url : www.google.com ? Also, the
customer result from the variable iteration
component.set('v.mycolumns'is not displaying the result.
Rather it displaying the static value : Customer Name
lightning lightning-experience slds datatable lightning-datatable
I am trying to insert a link in a result column of lightning:datatable
Below is the code snippet :
Datatable Code:
<lightning:datatable data="! v.contactList "
columns="! v.mycolumns "
keyField="id"
onrowselection = "!c.checkboxFetch"
hideCheckboxColumn="false"
onrowaction="!c.checkboxFetch"
class="tableCss"
tabindex="1"/>
Controller Code:
label: 'Customer Name', fieldName: 'CustomerName__c', type: 'url',
sortable:"false",
typeAttributes:
label: 'Customer Name',
fieldName: 'CustomerName__c',
title: 'View',
disabled: false,
value: 'view',
iconPosition: 'left',
url: 'www.google.com',
, ,
However, in the result I am not able to link the column with the mentioned url and when clicking on the hyperlink it is redirecting to a localhost url like 172.9.0.1 (something like this)
Any idea on how to redirect to the url : www.google.com ? Also, the
customer result from the variable iteration
component.set('v.mycolumns'is not displaying the result.
Rather it displaying the static value : Customer Name
lightning lightning-experience slds datatable lightning-datatable
lightning lightning-experience slds datatable lightning-datatable
edited Sep 16 at 11:57
asked Sep 16 at 11:16
Jayati Jaiswal
238
238
You have to set the columntypeasurland in in data, you have to separately define the link you want the users to redirect to. Have a look at this example provided in the documentation, developer.salesforce.com/docs/component-library/bundle/â¦
â Ranga
Sep 16 at 11:43
add a comment |Â
You have to set the columntypeasurland in in data, you have to separately define the link you want the users to redirect to. Have a look at this example provided in the documentation, developer.salesforce.com/docs/component-library/bundle/â¦
â Ranga
Sep 16 at 11:43
You have to set the column
type as url and in in data, you have to separately define the link you want the users to redirect to. Have a look at this example provided in the documentation, developer.salesforce.com/docs/component-library/bundle/â¦â Ranga
Sep 16 at 11:43
You have to set the column
type as url and in in data, you have to separately define the link you want the users to redirect to. Have a look at this example provided in the documentation, developer.salesforce.com/docs/component-library/bundle/â¦â Ranga
Sep 16 at 11:43
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
5
down vote
Your Type Attributes, and likely the underlying data, aren't set up properly for a url type entry.
Your url item should correspond to the column in your data that contains a URL value (not the link's title or the column title). You can use the typeAttributes map to supply three additional parameters:
- label
- target
- tooltip
Your columns entry should look something like this:
label: 'Customer Name',
fieldName: 'CustomerName__c', // This field should have the actual URL in it.
type: 'url',
sortable: "false",
typeAttributes:
label:
fieldName: 'UserReadableName__c'
// whatever field contains the actual label of the link
,
target: '_blank', // or as desired
tooltip: 'Open the customer page' // or as desired
Then, your CustomerName__c column in your data must contain an actual URL (not a Salesforce Id or anything else). If it doesn't, you can add a synthetic column to your data, such as
contactsList.forEach(function(contact)
contact.SearchURL = 'https://google.com/search?q=' + contact.CustomerName__c;
Thanks for the reply I am still not able to populate the url and getting the below error when tired the foreach approach : This page has an error. You might just need to refresh it. Action failed: c:dataTableCmp$controller$doInit [contactList is not defined] Failing descriptor: c:dataTableCmp$controller$doInit Adding the label, target, tooltip to the datatable typeAttributes does not work as it is showing blank value on the UI.
â Jayati Jaiswal
Sep 17 at 9:32
Well, you can't paste my code into a location wherecontactListis not defined. You may need to adapt this to fit the architecture of your component, and you certainly will need to wait to execute it until your server callback returns, if you're executing a query in an Apex controller.
â David Reed
Sep 17 at 13:16
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
Your Type Attributes, and likely the underlying data, aren't set up properly for a url type entry.
Your url item should correspond to the column in your data that contains a URL value (not the link's title or the column title). You can use the typeAttributes map to supply three additional parameters:
- label
- target
- tooltip
Your columns entry should look something like this:
label: 'Customer Name',
fieldName: 'CustomerName__c', // This field should have the actual URL in it.
type: 'url',
sortable: "false",
typeAttributes:
label:
fieldName: 'UserReadableName__c'
// whatever field contains the actual label of the link
,
target: '_blank', // or as desired
tooltip: 'Open the customer page' // or as desired
Then, your CustomerName__c column in your data must contain an actual URL (not a Salesforce Id or anything else). If it doesn't, you can add a synthetic column to your data, such as
contactsList.forEach(function(contact)
contact.SearchURL = 'https://google.com/search?q=' + contact.CustomerName__c;
Thanks for the reply I am still not able to populate the url and getting the below error when tired the foreach approach : This page has an error. You might just need to refresh it. Action failed: c:dataTableCmp$controller$doInit [contactList is not defined] Failing descriptor: c:dataTableCmp$controller$doInit Adding the label, target, tooltip to the datatable typeAttributes does not work as it is showing blank value on the UI.
â Jayati Jaiswal
Sep 17 at 9:32
Well, you can't paste my code into a location wherecontactListis not defined. You may need to adapt this to fit the architecture of your component, and you certainly will need to wait to execute it until your server callback returns, if you're executing a query in an Apex controller.
â David Reed
Sep 17 at 13:16
add a comment |Â
up vote
5
down vote
Your Type Attributes, and likely the underlying data, aren't set up properly for a url type entry.
Your url item should correspond to the column in your data that contains a URL value (not the link's title or the column title). You can use the typeAttributes map to supply three additional parameters:
- label
- target
- tooltip
Your columns entry should look something like this:
label: 'Customer Name',
fieldName: 'CustomerName__c', // This field should have the actual URL in it.
type: 'url',
sortable: "false",
typeAttributes:
label:
fieldName: 'UserReadableName__c'
// whatever field contains the actual label of the link
,
target: '_blank', // or as desired
tooltip: 'Open the customer page' // or as desired
Then, your CustomerName__c column in your data must contain an actual URL (not a Salesforce Id or anything else). If it doesn't, you can add a synthetic column to your data, such as
contactsList.forEach(function(contact)
contact.SearchURL = 'https://google.com/search?q=' + contact.CustomerName__c;
Thanks for the reply I am still not able to populate the url and getting the below error when tired the foreach approach : This page has an error. You might just need to refresh it. Action failed: c:dataTableCmp$controller$doInit [contactList is not defined] Failing descriptor: c:dataTableCmp$controller$doInit Adding the label, target, tooltip to the datatable typeAttributes does not work as it is showing blank value on the UI.
â Jayati Jaiswal
Sep 17 at 9:32
Well, you can't paste my code into a location wherecontactListis not defined. You may need to adapt this to fit the architecture of your component, and you certainly will need to wait to execute it until your server callback returns, if you're executing a query in an Apex controller.
â David Reed
Sep 17 at 13:16
add a comment |Â
up vote
5
down vote
up vote
5
down vote
Your Type Attributes, and likely the underlying data, aren't set up properly for a url type entry.
Your url item should correspond to the column in your data that contains a URL value (not the link's title or the column title). You can use the typeAttributes map to supply three additional parameters:
- label
- target
- tooltip
Your columns entry should look something like this:
label: 'Customer Name',
fieldName: 'CustomerName__c', // This field should have the actual URL in it.
type: 'url',
sortable: "false",
typeAttributes:
label:
fieldName: 'UserReadableName__c'
// whatever field contains the actual label of the link
,
target: '_blank', // or as desired
tooltip: 'Open the customer page' // or as desired
Then, your CustomerName__c column in your data must contain an actual URL (not a Salesforce Id or anything else). If it doesn't, you can add a synthetic column to your data, such as
contactsList.forEach(function(contact)
contact.SearchURL = 'https://google.com/search?q=' + contact.CustomerName__c;
Your Type Attributes, and likely the underlying data, aren't set up properly for a url type entry.
Your url item should correspond to the column in your data that contains a URL value (not the link's title or the column title). You can use the typeAttributes map to supply three additional parameters:
- label
- target
- tooltip
Your columns entry should look something like this:
label: 'Customer Name',
fieldName: 'CustomerName__c', // This field should have the actual URL in it.
type: 'url',
sortable: "false",
typeAttributes:
label:
fieldName: 'UserReadableName__c'
// whatever field contains the actual label of the link
,
target: '_blank', // or as desired
tooltip: 'Open the customer page' // or as desired
Then, your CustomerName__c column in your data must contain an actual URL (not a Salesforce Id or anything else). If it doesn't, you can add a synthetic column to your data, such as
contactsList.forEach(function(contact)
contact.SearchURL = 'https://google.com/search?q=' + contact.CustomerName__c;
answered Sep 16 at 14:07
David Reed
20.6k31640
20.6k31640
Thanks for the reply I am still not able to populate the url and getting the below error when tired the foreach approach : This page has an error. You might just need to refresh it. Action failed: c:dataTableCmp$controller$doInit [contactList is not defined] Failing descriptor: c:dataTableCmp$controller$doInit Adding the label, target, tooltip to the datatable typeAttributes does not work as it is showing blank value on the UI.
â Jayati Jaiswal
Sep 17 at 9:32
Well, you can't paste my code into a location wherecontactListis not defined. You may need to adapt this to fit the architecture of your component, and you certainly will need to wait to execute it until your server callback returns, if you're executing a query in an Apex controller.
â David Reed
Sep 17 at 13:16
add a comment |Â
Thanks for the reply I am still not able to populate the url and getting the below error when tired the foreach approach : This page has an error. You might just need to refresh it. Action failed: c:dataTableCmp$controller$doInit [contactList is not defined] Failing descriptor: c:dataTableCmp$controller$doInit Adding the label, target, tooltip to the datatable typeAttributes does not work as it is showing blank value on the UI.
â Jayati Jaiswal
Sep 17 at 9:32
Well, you can't paste my code into a location wherecontactListis not defined. You may need to adapt this to fit the architecture of your component, and you certainly will need to wait to execute it until your server callback returns, if you're executing a query in an Apex controller.
â David Reed
Sep 17 at 13:16
Thanks for the reply I am still not able to populate the url and getting the below error when tired the foreach approach : This page has an error. You might just need to refresh it. Action failed: c:dataTableCmp$controller$doInit [contactList is not defined] Failing descriptor: c:dataTableCmp$controller$doInit Adding the label, target, tooltip to the datatable typeAttributes does not work as it is showing blank value on the UI.
â Jayati Jaiswal
Sep 17 at 9:32
Thanks for the reply I am still not able to populate the url and getting the below error when tired the foreach approach : This page has an error. You might just need to refresh it. Action failed: c:dataTableCmp$controller$doInit [contactList is not defined] Failing descriptor: c:dataTableCmp$controller$doInit Adding the label, target, tooltip to the datatable typeAttributes does not work as it is showing blank value on the UI.
â Jayati Jaiswal
Sep 17 at 9:32
Well, you can't paste my code into a location where
contactList is not defined. You may need to adapt this to fit the architecture of your component, and you certainly will need to wait to execute it until your server callback returns, if you're executing a query in an Apex controller.â David Reed
Sep 17 at 13:16
Well, you can't paste my code into a location where
contactList is not defined. You may need to adapt this to fit the architecture of your component, and you certainly will need to wait to execute it until your server callback returns, if you're executing a query in an Apex controller.â David Reed
Sep 17 at 13:16
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f232660%2finsert-a-link-in-lightning-datatable-column-value%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
You have to set the column
typeasurland in in data, you have to separately define the link you want the users to redirect to. Have a look at this example provided in the documentation, developer.salesforce.com/docs/component-library/bundle/â¦â Ranga
Sep 16 at 11:43