Styling Editable, Read-Only & Edited Cells
Summary
- AdapTable allows developers to specify which cells in AG Grid are editable or read-only
- Both these types of cells (as well as previously edited) can be specifically styled for easy identification
You might wish to visually indicate to your users which Cells in AG Grid are editable or read-only.
This is particularly the case if editability is set at the Grid Cell, rather than Column, level.
Find Out More
- See Pre Edit Validation for instructions on using isCellEditable function in Edit Options to set cell level editability
- This takes precedence over
ColDef.editablein Grid Options - see Setting Cell Editability Tutorial for more details
Additionally you might want to show which cells have been edited (with an option to undo the edit).
Styling can be provided via 3 parallel functions in User Interface Options:
Hint
Typically users will provide one, but not both, of the first 2 functions
editableCellStylesets the style for editable cellsreadOnlyCellStylesets the style for readonly cellseditedCellStylesets the style for edited cells
All 3 functions use the commonly used Adaptable Style object which can style a Cell in many ways.
Styling Editable Cells
Use the editableCellStyle property to set a Style for all editable Cells in the Grid.
editableCellStyle
- In this example we provide an
editableCellStyle(in User Interface Options) of a yellow border with a radius so that editable cells to be readily identified - We also provide 3 Editable cell Rules - set using
isCellEditableproperty in Edit Options:- All cells in a row where
Languagecell value is HTML are editable GitHub Watchersis editable for cells with a value over 1,000Issue Changeis always editable
- All cells in a row where
Expand to see the Adaptable Options code
Styling Read-Only Cells
Use the readOnlyCellStyle property to set a Style for all read-ony Cells in the Grid.
Deep Dive
How AdapTable asseses whether a Cell is Read-Only
readOnlyCellStyle
- In this example we provide a
readOnlyCellStyle(in User Interface Options) of a gray background so that read-only cells can be readily identified - We provide 3 Read-only cell Rules - set using
isCellEditableproperty in Edit Options (same as in above example but inverted):- All cells in a row where
Languagecell value is HTML are read-only GitHub Watchersis read-only for cells with a value over 1,000Issue Changeis always read-only
- All cells in a row where
Expand to see the Adaptable Options code
Styling Edited Cells
Use the editedCellStyle property to set a Style for all Cells in the Grid which have been edited.
Hint
AdapTable leverages Data Change History to monitor which Cells have been edited, so ensure that is turned on
editedCellStyle
- In this example we provide a
editedCellStyle(in User Interface Options) of a gray background so that edited cells can be readily identified - We set Data Change History to be active by default and programatically edit 2 cells in the
Languagecolumn
Expand to see the code used
Find Out More
The Undoing Data Edits demo illustrates adding a custom Context Menu Item to edited cells to undo the edit