cancel
Showing results for 
Search instead for 
Did you mean: 

Back Navigation

Former Member
0 Kudos

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"

  }, ]

  },

  },

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi  Experts,

Do you have solution to this?

Former Member
0 Kudos

Closing the thread

Answers (1)

Answers (1)

Huiying
Explorer
0 Kudos

The Order should the same, then once you use the History system could work.