3

Currently when I use the lightning:datatable and then a column of type url. I cant seem to bind a actual event to the url.. My Code is currently as follows

Component

     <lightning:layoutItem size="12" >
            <lightning:datatable data="{! v.data }" title="{!v.title}"  
                                 columns="{! v.columns }" 
                                 keyField="{!v.keyField}"
                                 minColumnWidth="{!v.minColumnWidth}"
                                 hideCheckboxColumn="{v.hideCheckboxColumn}"
                                 resizeColumnDisabled="true"

                                 />
    </lightning:layoutItem>

Columns

var columns =  [
       // { type: 'action', typeAttributes: { rowActions: actions } }, 
        {label: 'Client Name'
         , fieldName: 'link'
         , type: 'url' 
         , typeAttributes: {
            label: { 
                fieldName: 'Name' 
            }
        }}
      ] ; 

    component.set("v.columns" , columns ) ; 

Rendering this out then doesnt seem to take any affect on the href

and only seems to affect the title attribute ..

enter image description here

enter image description here

Then in the docs can only see these two attributes available for a url

url
Displays a URL using lightning:formattedUrl
label, target

Any help is greatly appreciated

  • Looks like the Formatting with Data Types link is missing in the documentation. Where did you find the doc about the url type? – Martin Lezer Jan 29 '18 at 9:39
  • Hmm i found it fine Just here under "Formatting with Data Types" developer.salesforce.com/docs/atlas.en-us.lightning.meta/… – Thomas Woodhouse Jan 29 '18 at 9:55
  • There is also a value attribute: developer.salesforce.com/docs/atlas.en-us.lightning.meta/… – Martin Lezer Jan 29 '18 at 10:06
  • hmmm yes I seen that but binding to that doesnt seem to do anything ... It seems when the formatted url is used in the datatable the attributes that are actually available are label and target – Thomas Woodhouse Jan 29 '18 at 10:19
  • Just double checking again and binding to value like so still doesnt show any effect {label: 'Client Name' , fieldName: 'link' , type: 'url' ,initialWidth : 350 , typeAttributes: { label: { fieldName: 'Name' }, value: { fieldName: 'link' } }}, – Thomas Woodhouse Jan 29 '18 at 10:36
0

This seems to be working for me, my href correctly compiles to a salesforce id (with full regular non-lightning domain):

  {
    label: "SKU",
    fieldName: "Name_Link__c",
    type: "url",
    typeAttributes: {
      label: { fieldName: "Name" }
    },
    initialWidth: 100
  },

Name_Link__c is:

LEFT($Api.Partner_Server_URL_260, FIND( '/services', $Api.Partner_Server_URL_260))+Id
  • And this is working in a community is it ? I cant seem to bind a variable to what your putting in LEFT($Api.Partner_Server_URL_260, FIND( '/services', $Api.Partner_Server_URL_260))+Id – Thomas Woodhouse Feb 2 '18 at 9:41
  • Ah, community that URL won't work, that grabs the internal. There isn't an elegant way to get Community URL in formula afaik, but it should work even hardcoded. The datatable is getting that resolved formula value, whatever it is. – tsalb Feb 2 '18 at 13:43
  • I ended up logging a ticket with salesforce, and it turns out this was a spring 18 issues with lightning:formattedUrl which then also affected the lightning:datatable – Thomas Woodhouse Feb 5 '18 at 8:56
0

I ended up logging a ticket with salesforce, and it turns out this was a spring 18 issues with lightning:formattedUrl which then also affected the lightning:datatable

This is now going to be fixed in time for the full spring 18 release

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.