You need to sign in to do that
Don't have an account?
Raghu 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
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
I guess this can help you to get it done.
https://forceblogs.com/how-to-display-errors-in-lightning-datatable/
#validation #javascript #lightning-datatable
search for Displaying Errors.