1

I am trying to highlight a cell dynamically. I have used this link however I get an error.

Link: https://www.salesforcetroop.com/datatable_styling_in_lwc

HTML:

<lightning-datatable data={data} columns={columns} key-field="id" selected-rows={selectedRows}
                    onrowselection={handleSelectedRow}>
                </lightning-datatable>

JS:

const columns = [
    {
        label: 'EVENT REGISTRATION FIELD NAME', fieldName: 'eventregistrationfieldname', type: 'text',
        cellAttributes: { class: { fieldName: 'accountColor' } }
    },
    { label: 'SALESFORCE DATA', fieldName: 'salesforcedata', type: 'text' },
    { label: 'EVENT REGISTRATION DATA', fieldName: 'eventregistrationdata', type: 'text' }
];


GetData(){
    //call apex...
    let data = [];
    data.push({
                id: key,
                objectId: eventRegData[key].objectId,
                eventregistrationfieldname: eventRegData[key].label,
                salesforcedata: eventRegData[key].sfData,
                eventregistrationdata: eventRegData[key].regData,
                isSelected: eventRegData[key].isSelected,
                "accountColor": "datatable-orange" //does not work
            });
    this.data = registrationData;
}

CSS:

.datatable-orange {
    color: #fff;
    background-color: #e06000;
}

Error I receive:

Error: [LWC error]: Dynamically setting the "stylesheets" property on a template function is deprecated and may be removed in a future version of LWC.

enter image description here

3

0

You must log in to answer this question.

Browse other questions tagged .