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
Raghu Natha 2Raghu Natha 2 

LWC lightning data table on cell change data validation

Hi,

I awant to validate the data in a editable data table cell change event

<lightning-datatable                                                
        key-field="id"
        data={data}
        show-row-number-column
        row-number-offset={rowOffset}   
        onrowaction={handleRowAction}
        onsave={handleSave}
        columns={columns}
        oncellchange={validatecelldataset}
        draft-values={draftValues}
        errors={error}
>

In JS file 
validatecelldataset(event){ 
        console.log('Cell Data  : ' +JSON.stringify( event.detail.draftValues[0]));        
    }

How to validate the above data and send an error message.
In the columns array i do have the column name type, lenght, so the validations that I am looking for is to check against the data type and length in the JS method.

Tahnk you
itzmukeshy7itzmukeshy7

I guess this can help you to get it done.

https://forceblogs.com/how-to-display-errors-in-lightning-datatable/

#validation #javascript #lightning-datatable

itzmukeshy7itzmukeshy7
More on displaying errors you can find here https://developer.salesforce.com/docs/component-library/bundle/lightning:datatable/documentation
search for Displaying Errors.
Himanshu Sharma 241Himanshu Sharma 241
This is a common issue i think you can visit InstaLyrics (https://instalyrics.com/)