javascriptag-gridag-grid-reactag-grid-ng2ag-grid-validation

How to create Placeholder in AG-Grid Text field


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


Solution

  • We can use cellRenderer to do this like so!

    {
      headerName: 'Text Editor',
      field: 'color1',
      cellRenderer: (params) => params.value || <span class="light-color">'Click to edit!'</span>,
      cellEditor: 'agTextCellEditor',
      cellEditorParams: {
        maxLength: 20,
      },
    },
    

    plunkr