I have an editable ag-grid. How can I add placeholders to empty cells (they should disappear when cells are edited)?
cellEditor: 'agTextCellEditor',
cellEditorParams: (params) => {
debugger;
const { filterOptionKey, placeholder } = params;
return `Enter the Athelte`;
},
filter: 'agNumberColumnFilter',
filterParams: {
filterPlaceholder: 'Enter the Athelte '
}
},
we try the above code but its not working
2
Answers
We can use
valueFormatter
to do this like so!plunkr
In this example, the valueFormatter checks whether any cell is being edited using params.node.gridOptions.api.getEditingCells().length > 0. If a cell is being edited, it displays the actual value; otherwise, it displays the placeholder text. Note that this approach might not be as visually clean as using custom cell renderers, but it’s a simpler solution using the available options in ag-Grid.