最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - SAPUI5 How to clear combobox selection when a button is clicked? - Stack Overflow

programmeradmin2浏览0评论

I have a bobox that due to its nature it initializes without any item selected (figure 1). When I select an item, the selection is set (figure 2). Then, I have a button that when pressed it should make that bobox back to the first state, without any selection visible, "blank" basically (figure 1).

How can I get the button back to it's initial stage when a button is pressed?

figure 1

figure 2

I have a bobox that due to its nature it initializes without any item selected (figure 1). When I select an item, the selection is set (figure 2). Then, I have a button that when pressed it should make that bobox back to the first state, without any selection visible, "blank" basically (figure 1).

How can I get the button back to it's initial stage when a button is pressed?

figure 1

figure 2

Share Improve this question asked Feb 24, 2017 at 14:08 Diogo MagalhãesDiogo Magalhães 4612 gold badges10 silver badges19 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

try using smth like this in ur onPressButton function:

this.getView().byId("urComboBoxID").setValue(null)

it should now be initial

When button is pressed you can write in your controller:

var oComboBox = this.getView().byId("yourComboBoxId");
oComboBox.setSelectedKey("A");

And you can define key in you xml file:

<ComboBox id="yourComboBoxId" selectedKey="A" width="150px">
   <core:Item text="" key="A"  />
   <core:Item text="B" key="B" />
   <core:Item text="C" key="C" />
   <core:Item text="D" key="D" />
</ComboBox> 

EDITED 16:14 240217:

Example.

try this:

_YourCombobox.setSelectedKey("");
发布评论

评论列表(0)

  1. 暂无评论