[sapui5] remember this function pair when you want to fire Select on some items of ListBase

Hi,

Please remember 2 functions which always go in pair:
setSelectedItem(oItem);
fireSelect({key: sItemKey});
Example:
oTabBar.setSelectedItem(oTabBar.getItems()[0]);
oTabBar.fireSelect({key: oTabBar.getItems()[0].getId()});
If you're a newbie in sapui5 development, when you look up in the API, you may definitely think the only 1 function fireSlect() is enough to trigger the selectItem event of Listbase.

However, that function does not all the thing we want. The fireSelect() do select the new items to the Listbase, but it not set the property 'selectedItem' of that Listbase to correct Item. That's why we need to use setSelectedItem also to set the 'selectedItem' to correct value.

Hope this helps you in your development.

Cheer,

---V---

Nhận xét

Bài đăng phổ biến từ blog này

Tại sao lại chụp ảnh theo bố cục 1/3 ?

[sapui5] Best Practice in sapui5 development

Implement Search field with case-INSENSITIVE by SAP UI5