Reactjs 如何使用Ant Design表添加空白的可编辑行?
尝试创建一个“添加行”按钮,该按钮将向表中添加一个新的可填充/可编辑行。问题是,当我将可编辑字段设置为空字符串时,编辑字段不会显示,因此用户无法更改其内容:Reactjs 如何使用Ant Design表添加空白的可编辑行?,reactjs,antd,Reactjs,Antd,尝试创建一个“添加行”按钮,该按钮将向表中添加一个新的可填充/可编辑行。问题是,当我将可编辑字段设置为空字符串时,编辑字段不会显示,因此用户无法更改其内容: // RESULTS IN NO FIELD DISPLAYED const newCategoryRow = { key: 'NEW', acct: '', description: '', total: 0 } // RESULTS IN FIELD DISPLAYED const newCategor
// RESULTS IN NO FIELD DISPLAYED
const newCategoryRow = {
key: 'NEW',
acct: '',
description: '',
total: 0
}
// RESULTS IN FIELD DISPLAYED
const newCategoryRow = {
key: 'NEW',
acct: 'blah',
description: 'blah',
total: 0
}
有办法吗?将空字符串替换为“-” 或为可编辑单元格提供初始值:
const getInput = (props) => {
if (props.inputType === 'number')
return (
<Input
type={'number'}
style={{ margin: 0, padding: 4, fontSize: 13 }}
/>);
//Default field
else
return (
<Input
type={'text'}
style={{ margin: 0, padding: 5 }}
/>);
}
<Form.Item style={{ margin: 0 }}>
{props.form.getFieldDecorator(dataIndex,
{ initialValue: "-", })(getInput(props))}
</Form.Item>
const getInput=(道具)=>{
如果(props.inputType=='number')
返回(
);
//默认字段
其他的
返回(
);
}
{props.form.getFieldDecorator(数据索引,
{initialValue:“-”,}(getInput(props))}