Dear all,
I am facing a weird issue with the Eventbus when running the app on phones, it runs fine on dsktops. I have a fiori style master details app, the events are fired on the Master List view (when ever the list changes due to a filter selected) and subscribed in the details view (to hide some controls depending on the type of listing) . There are filters (lets say A & B) on the List view which changes what type of List items. if you select filter B, some controls in the detail view should be hidden.
Hiding controls in the details view works fine if I run the app on desktops, but fails on iPhones only on the first run.
say you run the app on the phone, by default A is selected. You have the list. select a filter B directly on the list (without going to the detail view) and then click on the item to display details. the event is not fired or subscribed
if you now select filter A, get the list - select an item to go to the details - the event is fired and subscribed in the detail page. It is as if the EventBus is not able to fire/subscribe on the first load of the app.
this is how the events are fired,
oFilterOptions:{ sId:"openBtn2", sI18nBtnTxt: 'Filter', onFilterPressed: jQuery.proxy(this._handleOptions,that) } _handleOptions: function(oEvent){ var sButtonId = oEvent.getSource().getId(); var sButtonText = oEvent.getSource().getText(); oListBindings = this.getList().getBinding('items'); var c = sap.ui.core.Component.getOwnerIdFor(that.oView), C = sap.ui.component(c); C.oEventBus.publish("zApp","showHideButtons",{id:sButtonId}); };
in the details view, this is how its subscribed
onInit: function() { that = this; var c = sap.ui.core.Component.getOwnerIdFor(this.oView), C = sap.ui.component(c); C.oEventBus.subscribe("zApp","showHideButtons", that._handleApprovalButtonsVisibility, this); }
_handleApprovalButtonsVisibility: function(channelId, eventId, data){ if(data.id==='B'){ //Hide the Reject, Approve Buttons this._oControlStore.oButtonListHelper.mButtons['btn_approve'].setVisible(false); }else if(data.id==='A') { this._oControlStore.oButtonListHelper.mButtons['btn_approve'].setVisible(true); } }
Appreciate any help.
Thanks
Sandip