I have a lightning data table displaying a set of Records. Also, it have inline editing set true for one column called Price.

Is it possible to have the Price column as Required while editing?

My Cmp code:

          max-row-selection =1

MY js:

 column = [
        { fieldName: 'Name', label: 'Name' },
        { fieldName: 'Description__c', label: 'Description' },


How to make price field as a required field in this table ?

  • If you can't set it as required field in the object, then you will have to handle it via code. I doubt if there is an OOB attribute by which you can mark it as required.
    – arut
    Commented Apr 23, 2021 at 17:27

1 Answer 1


There are a few scenarios you should consider when requiring / validating entry in a lightning-datatable.

Example Required Field in LWC Lightning Datatable

A custom "required input cell" with an asterisk on edit would only be possible if you create a custom data type, see the following resources:

OOTB - Required Field

If the field is configured, out of the box (OOTB), as required, then an error on the cell will display after you attempt a save. The DML operation will fail, and the standard table error will be returned: LWC Datatable: See section 'Displaying Errors'

OOTB - Apex (Triggers) / Validation Rules

When an error is added to a record during a DML operation, via configuration or Apex code, then those errors will propagate back to the LWC datatable as error messages at the table and row levels -- see above documentation 'Displaying Errors'.

Client side validation

If none of the above are configured in your org, then you can create an onsave handler in your JavaScript, check the validity of the table rows (both draftValues & existing table data), and if validation fails populate an error object that you pass back to the table error attribute. See above documentation 'Working with Inline Editing'

From a UI perspective you can always provide additional clarity on the required column.

You must log in to answer this question.

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