如何将选项标记为已选中

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

如何将所选属性设置为qazxsw poi组件内的选项?我还没有意识到如何设置选定的属性。

我已经尝试过选择一个属性,但它似乎没有用。

<SelectArrayInput>

我希望const tec = [ { name: "Apple", id: 1, selected: true}, { name: "Facebook", id: 2 }, { name: "Netflix", id: 3 }, { name: "Tesla", id: 4 }, ]; const ReferrenceSelectBox = ({ source, record = {} }) => <SelectArrayInput choices={ tec } />; ReferrenceSelectBox.propTypes = { label: PropTypes.string, record: PropTypes.object, source: PropTypes.string.isRequired, }; export default ReferrenceSelectBox; 的输出已经选择了。

reactjs material-ui react-admin
1个回答
0
投票

我无法获得使用<SelectArrayInput>的代码沙箱,但是从react-admin看起来它使用了Material-ui的documentation作为基础。

在Material-UI中,您可以传递要作为道具选择的值:Select,它采用您想要的value数组。

因此,在您的情况下,您可以创建另一个捕获ids并将其作为selected prop传递的数组,而不是使用selectedIds属性,它应该可以工作。

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