如何在 AG-Grid 文本字段中创建占位符

问题描述 投票:0回答:1

我有一个可编辑的农业网格。如何将占位符添加到空单元格(编辑单元格时它们应该消失)?

cellEditor: 'agTextCellEditor',
    cellEditorParams: (params) => {
        debugger;
    const { filterOptionKey, placeholder } = params;
    return `Enter the Athelte`;
  },
  filter: 'agNumberColumnFilter',
        filterParams: {
            filterPlaceholder: 'Enter the Athelte '
        }

}, 我们尝试了上面的代码,但它不起作用

javascript ag-grid ag-grid-react ag-grid-ng2 ag-grid-validation
1个回答
0
投票

我们可以使用

valueFormatter
来这样做!

{
  headerName: 'Text Editor',
  field: 'color1',
  valueFormatter: (params) => params.value || 'Click to edit!',
  cellEditor: 'agTextCellEditor',
  cellEditorParams: {
    maxLength: 20,
  },
},

plunkr

© www.soinside.com 2019 - 2024. All rights reserved.