0

The whole datatable looks fine, and hyperlinks are visible till using Search Bar. After writing dummy words - the data is showing correct, but without hyperlinks. What I missed?

I need to refresh whole page, to get hyperlinks back again.

enter image description here

enter image description here

  @wire(getWoliList,{ woid: '$recordId' })
    wiredOpps(result) {
        //this.result = wolis;
        
        this.wiredResult = result;
        const { data, error } = result;
        if(data) {
            
            console.log(data);
            this.data = data;
            this.initialRecords = data;
            let nameUrl, assetUrl, prodUrl;
            this.data = data.map(row => { 
                nameUrl = `/${row.Id}`;
                assetUrl = `/${row.AssetId}`;
                prodUrl = `/${row.PricebookEntryId}`;
                return {...row , nameUrl , assetUrl , prodUrl} 
            })
            this.error = null;
        }
        if(error) {
            this.error = error;
            this.data = [];
        }
    } 

    handleSearch(event) {
        const searchKey = event.target.value.toLowerCase();
 
        if (searchKey) {
            this.data = this.initialRecords;
 
            if (this.data) {
                let searchRecords = [];
 
                for (let record of this.data) {
                    let valuesArray = Object.values(record);
 
                    for (let val of valuesArray) {
                        console.log('val is ' + val);
                        let strVal = String(val);
 
                        if (strVal) {
 
                            if (strVal.toLowerCase().includes(searchKey)) {
                                searchRecords.push(record);
                                break;
                            }
                        }
                    }
                }
 
                console.log('Matched Wolis are ' + JSON.stringify(searchRecords));
                this.data = searchRecords;
                return refreshApex(this.wiredResult);
            }
        } else {
            this.data = this.initialRecords;
            return refreshApex(this.wiredResult);
        }
    }

1 Answer 1

0

It was fast, I know the answear. I am leaving fixed piece of code, if someone will have the same problem:

I added this.initialRecords and created a map.

@wire(getWoliList,{ woid: '$recordId' })
    wiredOpps(result) {
        //this.result = wolis;
        
        this.wiredResult = result;
        const { data, error } = result;
        if(data) {
            
            console.log(data);
            this.data = data;
            this.initialRecords = data;
            let nameUrl, assetUrl, prodUrl;
            this.data = data.map(row => { 
                nameUrl = `/${row.Id}`;
                assetUrl = `/${row.AssetId}`;
                prodUrl = `/${row.PricebookEntryId}`;
                return {...row , nameUrl , assetUrl , prodUrl} 
            })
            this.error = null;

            this.initialRecords = data.map(row => { 
                nameUrl = `/${row.Id}`;
                assetUrl = `/${row.AssetId}`;
                prodUrl = `/${row.PricebookEntryId}`;
                return {...row , nameUrl , assetUrl , prodUrl} 
            })
            this.error = null;
        }
        if(error) {
            this.error = error;
            this.data = [];
        }
    } 

    handleSearch(event) {
        const searchKey = event.target.value.toLowerCase();
 
        if (searchKey) {
            this.data = this.initialRecords;
 
            if (this.data) {
                let searchRecords = [];
 
                for (let record of this.data) {
                    let valuesArray = Object.values(record);
 
                    for (let val of valuesArray) {
                        console.log('val is ' + val);
                        let strVal = String(val);
 
                        if (strVal) {
 
                            if (strVal.toLowerCase().includes(searchKey)) {
                                searchRecords.push(record);
                                break;
                            }
                        }
                    }
                }
 
                console.log('Matched Wolis are ' + JSON.stringify(searchRecords));
                this.data = searchRecords;
                return refreshApex(this.wiredResult);
            }
        } else {
            this.data = this.initialRecords;
            return refreshApex(this.wiredResult);
        }
    }

You must log in to answer this question.

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