React-Admin,根据ReferenceInput清空ArrayInput

时间:2018-06-04 11:03:56

标签: reactjs react-admin

我有一个代码如下(我在前端使用react-admin);

<ReferenceInput label="DataPoint Types" source="datapointtype" reference="datapointtypes" onChange={this.dptChanged}>
    <SelectInput optionText="id" />
</ReferenceInput>
<ArrayInput source='parameters'>
    <SimpleFormIterator>
        <TextInput source='id' label="name" validate {this.validateParameterName} />
        <ReferenceInput label="Parameter DataType" source="parameters" reference="datatypes">
            <SelectInput optionText="id" source="id" />
        </ReferenceInput>
    </SimpleFormIterator>
</ArrayInput>

更改功能;

dptChanged(event) {
    const dataPointType = Object.values(event).slice(0, -1).join('');
    axios.get('http://localhost:3001/designer/datapointtypes/' + dataPointType)
        .then(response => {
            if (response.data.parameters) {
                this.setState({
                    connectedParameters: Object.values(response.data.parameters)
                })
            }
        });

    axios.get('http://localhost:3001/designer/datatypes')
        .then(response => {
            this.setState({
                datatypes: response.data
            })
        })
}

我想要做的就是这样;当我更改SelectInput(datapointtype)时,&#34;参数&#34; ArrayInput必须为空,即使它有元素。

我该怎么做?

0 个答案:

没有答案