Validating Data in AdapTable

View as Markdown

Summary

  • AdapTable provides 3 types of validation:
    • Pre-edit validation via read-only cells
    • Post-edit client validation via Validation Alerts
    • Post-edit server validation via validateOnServer

Users and developers can validate AG Grid edits in three layers, depending on whether you block editing upfront or judge the proposed new value:

LayerEvaluatesTypical use
Pre-Edit ValidationCurrent cell / row contextCell must not enter edit mode (for example locked rows or values)
Client ValidationNew value (Prevent Edit alerts)Editable cell, but this value is not allowed; roll back immediately
Server ValidationNew value (async function)Allow, revert, or substitute a value after a server or external check

Client validation runs before server validation: validateOnServer is invoked only after client checks (including Prevent Edit alerts) succeed.

Pre-editing Validation

Pre-editing validation is performed using Read-Only (or editable) cells.

AdapTable prevents cells which meet the read-only rule from being edited before a new value can be provided.

Note

  • AdapTable evaluates whether the cell can be edited using the existing cell value (and row context)
  • It does not evaluate the value the user is entering

Find Out More

See Pre-Edit Validation for isCellEditable and styling read-only cells.

Post-editing Client Validation

AdapTable can be configured with Validation Alerts which trigger when an edit breaks an Alert rule.

Alerts with PreventEdit roll the data change back automatically.

Validation Alerts can be defined at design-time in Alert State, or created at run-time by users.

Find Out More

Post-editing Server Validation

AdapTable offers Server Validation through Edit Options (validateOnServer).

An async function receives details of the proposed edit and returns whether to allow it, revert to the old value, or apply a different value—with an optional notification.

Find Out More

See Server Validation for ServerValidationResult and message options.

Data Validation
Fork
  • This example shows all 3 types of validation (using the language column):
    • Pre-editing Validation sets all cells with the value HTML to be read-only
    • Client Validation prevents the value being changed to Python
    • Server Validation has 2 rules: (1) it disallows the value JQuery; (2) it changes a value of C to C#
  • Configuration is in adaptableOptions.ts
Try It Out
  • In the Language column:
    • try to change a cell with HTML and note it's not allowed; change a different cell to HTML and note the new cell is now not editable
    • change a cell to Python and see how it triggers a Prevent Edit Alert
    • change a cell to JQuery and see how it gets reverted; set it to C and note how it gets automatically updated to C#
Loading demo…

FAQ

Do I need all three mechanisms? No. Use pre-edit when the cell should not be editable at all. Use client Prevent Edit alerts for fast feedback on invalid new values. Use server validation when the decision belongs on the server or needs async logic.

Does pre-edit block programmatic updates? No. isCellEditable guards user-driven UI edits only; programmatic updates (for example ticking data) can still change the grid. See Pre-Edit Validation.