如何将密钥检索到语义用户界面反应下拉列表中? [英] How to retrieve the key into a Semantic-ui-react dropdown?
本文介绍了如何将密钥检索到语义用户界面反应下拉列表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对react下拉菜单有一个小问题.
I have small question about react dropdown menus.
我可以提取下拉列表中的值,但是我也需要密钥,因为我的页面用于销售东西.因此,这是一个关联表,我需要每个表的ID来进行查询 INNERJOIN .
I can extract the values inside the dropdown, but I also need the key, because my page is for selling stuff. So, it is an associative table and I need the id from each table to make my query INNERJOIN.
这是我填写的方式:
let options_customers = [];
serviceList[0].map((service, i) =>
options_customers.push({
key: service.Id,
text: service.Name,
value: service.Name
}))
我的下拉菜单:
<Dropdown
selection options={options_customers}
onChange={this.handleChange}
value={value} key={options_customers.key}
name="selectCustomer" placeholder='Select Customer'
/>
推荐答案
您可以使用在data
到onChange
函数中使用的value
来选择正确的选项并从中获取密钥:
You can use the value
you get in the data
to the onChange
function to take out the right option and take the key from that:
handleChange(event, data) {
const { value } = data;
const { key } = data.options.find(o => o.value === value);
}
这篇关于如何将密钥检索到语义用户界面反应下拉列表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文