0

Ref: https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/example

For a lightning data table with inline edit function. I am trying to understand how to call a JS validation when the user edits a column in a LWC lightning data table and Tabs out of the column. (Instead of checking this onSave functionality)

Also, by default if the column is email field or website an inbuilt client side validation is invoked to check the format of website or email, (In the same way can I also validate the length of the fields ?? )

Thank you, Raghu

1

I would imagine that you are referring to tab out from a cell instead of a column. If that's what you mean, you can capture it using oncellchange event.

From documentation:

You can handle the oncancel, oncellchange, and onsave actions when the cell value changes or is saved. When the onsave action is used, the Cancel and Save button appears after a value cell changes and you press the Enter or Tab key, or move away from the cell.

Remember though, you will need to manipulate the values in the cell to be able to perform any validation as this event will be fired from any cell change and tab outs.

My personal approach will not to implement any validations on tab if you are really looking to edit things in table but wait until you are saving the table so that you are able to reduce the multiple back and forth communication.

| improve this answer | |
  • Thank you Jayant, Yes I was looking for onCellChange. – Raghu Sep 25 '19 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.