Bài đăng

Đang hiển thị bài đăng từ Tháng 8, 2017

[sapui5] aggregation binding - Use Control Visible instead removeItem or destroyItem

Hình ảnh
Hi, You may be working with binding items in table or list, we call it aggregation binding in common. You may encounter some case where you need to hide some item in the list. If it's the case, remember to look at my practice: User item's visibility instead of remove or destroy that item in the list. Because  remove  or  destroy will remove the item from the HTML document, but still leave the Id of the HTML object there. If you make some time to the table that changes the items, the table rebind and you will get id duplication error . On the other hands, if you just hide the item by using the visible property of ListBaseItem, the control is still there (only hidden). Which leads to no id error. ---V---

[sapui5] Always remember to pass controller object when initiate fragment

Hình ảnh
Hi, I've got painful days searching to get this error. Here's the problem: Problem I can not get any event in above table. When I press the button, it does not trigger the function in the controller. I don't know why... until today. UI design Reason The problem comes from my initiation of the fragment to be used as table items. Each fragment to have a controller, but my code make the fragment get the wrong controller, Instead of getting controller of that view, they misunderstood with the window object, because I initiate the fragment where the context of this is the window object: The code in the browser console It's good to init your controller's properties in the top to provide an overview of global properties. But be aware of this keyword, which is very dynamic in Javascript. Solution If you init fragment to use in the view, init it in the event onInit() of view is the best, which the controller already loaded into this  key word: