Pre-Edit Validation

View as Markdown

Summary

  • AdapTable allows developers to specify which columns / cells in AG Grid are editable and which are read-only
  • Both editable and read-only cells can be specifically styled for easy identification

AdapTable provides Pre-Edit validation - which prevents read-only cells from being edited.

Note

  • Read-only and editable cell evaluation is performed on the current cell value, i.e. before any cell editing happens
  • This is different to Client Validation and Server Validation which both evaluate the proposed new cell value

AdapTable fully respects as read-only any Column Definitions configured with editable as false in AG Grid GridOptions (including if editability is set via a function).

But sometimes a more granular or dynamic approach is required, where the editability of each cell in the same column is dependent on its value (or other data in the same row).

Hint

Although AdapTable respects editability set in an AG Grid column definition, we advise using the function below instead

Setting Editable Cells

The isCellEditable function in Edit Options enables editability evaluation to be made on a per-cell basis.

isCellEditable

Function which sets if a cell is editable

Caution

This takes precedence over the colDef.editable property in GridOptions

Find Out More

See the Developer Tutorial on Setting Cell Editability for more details on how AdapTable evaluates cell editability

Styling Editable / ReadOnly Cells

When using the isCellEditable function, you might wish also to visually indicate to your users which Cells in AG Grid are editable.

Use editableCellStyle and readOnlyCellStyle in User Interface Options to achieve this.

Editable Cells
Fork
  • Three read-only rules in adaptableOptions.ts via isCellEditable in Edit Options:
    • No cell in any row where language is HTML is editable
    • github_stars is not editable when the value is over 20,000
    • name is not editable where week_issue_change is negative
  • readOnlyCellStyle in User Interface Options adds a brown border and radius on read-only cells
Loading demo…