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
BHASKAR GANGULYBHASKAR GANGULY 

Hyperlink not working in LWC in datatable

Hi,
I want to dispay Name field as hyperlink in the datatable in lwc.below JS is not working as expected.i am getting blank rows.however i can see the linkName is returning value in console.log.I was albel to do that through lightning component but not sure why its not returning.
below is the JS file.

import { LightningElement, track } from 'lwc';
import serachAccs from '@salesforce/apex/accountSearchController.retriveAccs';
// datatable columns
const columns = [
    {
        label: 'Account Name', fieldName: 'linkName', type: 'url', sortable: true, 
        typeAttributes: {label: { fieldName: 'Name' }, target: '_blank'}
    }, 
]
export default class AccountSearch extends LightningElement {
    @track searchData;
    @track columns = columns;
    @track errorMsg = '';
    strSearchAccName = '';
    
    handleAccountName(event) {
        this.strSearchAccName = event.detail.value;
    }
    handleSearch() {
        if(!this.strSearchAccName) {
            this.errorMsg = 'Please enter account name to search.';
            this.searchData = undefined;
            return;
        }
        serachAccs({strAccName : this.strSearchAccName})
        .then(result => {
           // console.log(result);
          // result = Object.assign({}, result);
           result.forEach(function(item) {
            let obj = {linkName: '/' + item.Id};
            let clone = Object.assign({}, obj);
           // ChromeSamples.log(clone);
            // Object.assign({item.linkName:item.Id});
            console.log(item.Id);
           // item.linkName= '/' + item.Id;
            console.log("This is"+obj.linkName);
        });
         this.searchData = result;
       
        })
      
    }
}
Please help.
ANUTEJANUTEJ (Salesforce Developers) 
Hi Bhaskar,

I am not sure why it might not be working but can you try setting the font color or the backgroung to black for the table cells to see if they are being displayed or not in case if they are not displayed the issue might be with the table code.

Regards,
Anutej