Implement cell editing using custom cell renderers
Cell editing in LightGrid is achieved by creating a custom cell renderer component. The recommended pattern for an editable cell involves a state-driven toggle between a read-only view and an edit view. The typical workflow is:
- Read-only Mode: The cell renders the current value.
- Trigger: The component listens for a double-click event to switch to edit mode.
- Edit Mode: The cell renders an input field. The editing state is kept internal to the cell component as the user types.
- Commit/Cancel:
- Pressing Enter triggers an
onCommitcallback to update the underlying data. - Pressing Escape cancels the changes.
- Pressing Enter triggers an
- Reset: After commit or cancel, the cell returns to read-only mode.