尝试创建“添加行”按钮,从而导致将新的可填充/可编辑行添加到表中。问题是,当我将可编辑字段设置为空字符串时,该编辑字段不会显示,因此用户无法更改其内容:
// 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
}
有什么办法吗?
答案 0 :(得分: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>