Use this file to discover all available pages before exploring further.
The ICellEditorComp interface allows you to create custom components for editing cell values in AG Grid. Cell editors control how users can modify data in editable cells.
interface ICellEditorComp<TData = any, TValue = any, TContext = any> extends ICellEditor<TValue>, IPopupComponent<ICellEditorParams<TData, TValue, TContext>> { /** Mandatory - Return the final value */ getValue(): TValue | null | undefined; /** Optional: Called once after editing is complete */ isCancelBeforeStart?(): boolean; /** Optional: Called once after editing is complete */ isCancelAfterEnd?(): boolean; /** Optional: Gets called when focus should be put into the editor */ focusIn?(): void; /** Optional: If doing full line edit, then gets called when focus is leaving the editor */ focusOut?(): void; /** Optional: A hook to perform any necessary operation just after the GUI has been rendered */ afterGuiAttached?(): void; /** Optional: If true, editor appears in a popup */ isPopup?(): boolean; /** Optional: Gets called with the latest cell editor params every time they update */ refresh?(params: ICellEditorParams<TData, TValue>): void;}
Key value of key that started the edit, eg ‘Enter’ or ‘F2’ - non-printable characters appear here.
init(params) { if (params.eventKey && params.eventKey.length === 1) { // User typed a character to start editing this.input.value = params.eventKey; }}
If doing full row edit, this is true if the cell is the one that started the edit (eg it is the cell the user double clicked on, or pressed a key on etc).
afterGuiAttached() { if (this.params.cellStartedEdit) { // Put focus on this editor this.input.focus(); this.input.select(); }}
A reference to the DOM element representing the grid cell that your component will live inside. Useful if you want to add event listeners or classes at this level.
Callback to tell grid to stop editing the current cell. Call with input parameter true to prevent focus from moving to the next cell after editing stops in case the grid property enterNavigatesVerticallyAfterEdit=true.
Optional: Gets called once after initialised. If you return true, the editor will not be used and the grid will continue editing. Use this to make a decision on editing inside the init() function.
isCancelBeforeStart() { // Only start editing if value is not null return this.params.value == null;}
Optional: Gets called once after editing is complete. If your return true, then the new value will not be used. The editing will have no impact on the record.
isCancelAfterEnd() { // Cancel if value hasn't changed return this.getValue() === this.params.value;}
Optional: A hook to perform any necessary operation just after the GUI for this component has been rendered on the screen. This is useful for any logic that requires attachment before executing, such as putting focus on a particular DOM element.
afterGuiAttached() { // Focus the input and select all text this.input.focus(); this.input.select();}
Optional: Gets called once after initialised. If you return true, the editor will appear in a popup, so is not constrained to the boundaries of the cell.
isPopup() { return true; // Editor will appear in a popup}
Optional: Gets called once, only if isPopup() returns true. Return “over” if the popup should cover the cell, or “under” if it should be positioned below leaving the cell value visible.
getPopupPosition() { return 'under'; // Popup appears below the cell}
Optional: The error messages associated with the Editor.
getValidationErrors() { const value = this.input.value; if (!value) { return ['Value is required']; } if (value.length < 3) { return ['Value must be at least 3 characters']; } return null;}