Sapui5 如何在sap.m.select中设置/获取所选文本?
我只在中找到Sapui5 如何在sap.m.select中设置/获取所选文本?,sapui5,sap-fiori,Sapui5,Sap Fiori,我只在中找到setSelectedItemsetSelectedItemIdsetSelectedKey如何在sap.m.select中设置选中的文本 例如: <Select forceSelection="false" selectedKey="{/ProductCollection/0/ProductId}" items="{
setSelectedItem
setSelectedItemId
setSelectedKey
如何在sap.m.select中设置选中的文本
例如:
<Select
forceSelection="false"
selectedKey="{/ProductCollection/0/ProductId}"
items="{
path: '/ProductCollection',
sorter: { path: 'Name' }
}">
<core:Item key="{ProductId}" text="{Name}" />
</Select>`
`
如何获取此控件中的选定文本(名称) 键应是唯一的,但文本不必是唯一的。在某些情况下,文本被翻译,但键保持不变。这就是为什么按键用于选择
要获取所选项目的文本,可以使用
var text = select.getSelectedItem().getText();
要通过文本选择项目,您必须在模型中搜索该项目,获取其密钥并将其与setSelectedKey()
一起使用