Skip to Content
0
Former Member
Jul 03, 2015 at 07:42 AM

Back Navigation

222 Views

Hi All,

I has back button in Goods.view.XML and the handler present in Goods.controller.js.

I want to navigate back to Master.view.XML , but i am not able to since my onRouteMatched is getting called for Master controller than Goods controller.

I dont understand why it is calling Goods onRouteMatched

Code

-----------------------------------------

onNavBack : function()

{

// This is only relevant when running on phone devices

var oHistory = sap.ui.core.routing.History.getInstance();

var sPreviousHash = oHistory.getPreviousHash();

//The history contains a previous entry

if (sPreviousHash !== "") {

window.history.go(-1);

} else {

var bReplace = true; // otherwise we go backwards with a forward history

detailView.router.navTo("master",{},bReplace);

}

},

---------------------------------

Master.controller.JS

onInit : function()

{

selfView.router = sap.ui.core.UIComponent.getRouterFor(this); selfView.router.attachRoutePatternMatched(this.onRouteMatched, this);

},

onRouteMatche: function() { debugger; selfView.getUnitDetails(); sap.ui.getCore() .getElementById("Master--idItemDetails") .setVisible(false); this.byId("idDocumentDate").setDateValue(new Date()); this.byId("idPostingDate").setDateValue(new Date()); this.byId("idDocumentDate").setEnabled(false); },

Goods.controller.js

-----------------------------------

onInit : function ()

{

detailView.router = sap.ui.core.UIComponent.getRouterFor(this);

detailView.router.attachRoutePatternMatched(this.onRouteMatched, this);

}

onRouteMatched : function(oEvent) {

debugger;

console.log("Goods");

var oParameters = oEvent.getParameters();

detailView.getItems(oEvent.getParameters().arguments);

},

Component.js

---------------------------

routing : {

config : {

viewType : "XML",

viewPath : "cgi_GoodsReceipt_GRN.view",

targetControl : 'mainContent',

// targetAggregation : "pages",

clearTarget : false,

transition : 'slide'

},

routes : [ {

pattern : "",

name : "master",

view : "Master",

viewLevel : 0

},

{

pattern : "Goods/{Mblnr}/{Mjahr}",

name : "Goods",

view : "Goods",

viewLevel : 3,

targetAggregation: "pages"

}, ]

},

},