Reputation: 361
I have a view that contains several ComboBox elements. For some reason old data remains from the previous time the view was opened and I would like to reset the combobox elements in the view every time it is opened. Is there a function that could that for me? I want it to be exactly how it is as if I rendered it the first time with the initial items. Would using setSelectedItem(vItem)
, setSelectedItemId(vItem)
, setSelectedKey(sKey)
, setShowSecondaryValues()
help? If so, what do these keywords mean (selectedItem, selectedItemID, selectedKey, secondaryValues)?
Upvotes: 1
Views: 4002
Reputation: 4231
Unfortunately you do not provide an example. Normally you bind your UI controls against a model, e.g. JSONModel. In this case the items of your ComboBox controls would be taken from the corresponding model. However, you can use method removeAllItems to achieve the desired behaviour.
UPDATE: Obviously the controls are bound and only the selection should be cleared.
Use setSelectedItem with value null
to clear the selection. You could also use the binding to set the selected item automatically by using the selectedKey attribute, see example.
Upvotes: 2