Reputation: 85
I have started using ag-grid in my react project, and was unable to find any API's for performing in-line cell validations i.e. whenever user edits a particular cell, the requirement is to perform a required field and pattern validation. In case of any validation errors, the corresponding editable field should get highlighted and an error message needs to be displayed.
I have used the following cell events to fulfill the above purpose, but none of them provided me the desired result.
cellEditingStarted
cellEditingStopped
Upvotes: 2
Views: 3889
Reputation: 1971
You may want to consider using the valueParser
option on the column definition for the column that you are editing. Here is an example where I have used it in the past:
valueParser: (params: ValueParserParams) => {
try {
let index = users.indexOf(params.newValue);
return index > -1 ? index : null;
} catch (e) {
console.error(e);
return null;
}
}
Personally, I usually would use onCellValueChanged
for performing validations, which is a property on the grid directly.
Upvotes: 1