I use select-field from material-ui framework of latest 0.15.4 version with react of version 15.4.0. I try to add blank menu-item to select-field to be able to diselect value for 'dropdown' field when I click on it. When I try to add it in the way like
<MenuItem value="" primaryText="" />
it doesn't appear in the dropdown list of items. What is the proper way to add functionality of selection blank field in SelectField?
I use select-field from material-ui framework of latest 0.15.4 version with react of version 15.4.0. I try to add blank menu-item to select-field to be able to diselect value for 'dropdown' field when I click on it. When I try to add it in the way like
<MenuItem value="" primaryText="" />
it doesn't appear in the dropdown list of items. What is the proper way to add functionality of selection blank field in SelectField?
Share Improve this question asked Aug 18, 2016 at 7:41 yavalvasyavalvas 3302 silver badges17 bronze badges 1- Maybe you should use a Divider – Mario Santini Commented Aug 18, 2016 at 7:46
1 Answer
Reset to default 5setting the MenuItem value to "" and primaryText to "" will make it invisible in the choices.
I suggest you do this:
<SelectField value={this.state.some_key}>
<MenuItem value="Choice1" primaryText="Choice1" />
<MenuItem value="Select" primaryText="Select" />
</SelectField>
and then on onChange:
onChange = (event, index, value) => {
if(value === "Select") {
this.setState({some_key = ""})
}
}
This will show blank input on the field once the "Select" is clicked.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744219514a4563711.html
评论列表(0条)