0 votes
1 view
in SAP by (7k points)

I want to pass parameters from master page to detail page on press of ListItem
 

handleListItemPress : function (evt ) {

 imp =  evt.getSource().getTitle();
  alert(imp);

//  var mystring = 'this,is,an,example';
  var splits = imp.split(",");


  dino     = splits[0];  //I want to send three parameters
  revno    = splits[1];
  uruntipi = splits[2];

    var context = evt.getSource().getBindingContext();
    this.nav.to("Detail", context);
},


I want to get parameter detail page onInit function.

1 Answer

0 votes
by (14.5k points)

handleListItemPress: function (evt) {

    var imp = evt.getSource().getTitle(); //don't declare globals variables

    //  var mystring = 'this,is,an,example';

    var splits = imp.split(",");

    //build json object with all your properties you want to send

    var context = {

        dino: splits[0],

        revno: splits[1],

        uruntipi = splits[2],

        bindingContext = evt.getSource().getBindingContext()

    };

    this.oRouter.navTo("Detail", context);

    //OR sap.ui.core.UIComponent.getRouterFor(this).navTo("Detail", context);

    //this.nav.to("Detail", context);

}

In Detail Page:

 onInit: function () {

     var oRouter = sap.ui.core.routing.Router.getRouter("appRouter");

     //can also use directly this.oRouter.attachRouteMatched(...)

     oRouter.attachRouteMatched(function (oEvent) {

         if (oEvent.getParameter("name") !== "detail") {

             return:

         }

         var dino = oEvent.getParameter("arguments").dino;

         var revno = oEvent.getParameter("arguments").revno;

         var uruntipi = oEvent.getParameter("arguments").uruntipi;

         var bindingContext = oEvent.getParameter("arguments").bindingContext;

     }, this);

 }

Read more here Methods and Events for Navigation

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...