Hi Gurus,
I am developing one Master-Detail scenario in SAPUI5. I have a Master view in Javascript and Detail View in Java Script.
The master is displaying one list of type navigation and when user selects the list, I want to display the selected line in Detail View. I have used Routes for the navigation and the routes are configured in my Component.js as below:
routing : { | ||||
config : { | ||||
viewType :"JS", | ||||
viewPath : "views", | ||||
targetControl : "navContainer", | ||||
targetAggregation : "detailPages", | ||||
clearTarget : false, | ||||
}, | ||||
routes : [ | ||||
{ | ||||
pattern:"", // default view | ||||
name:"main", | ||||
view:"MainView", | ||||
targetAggregation : "masterPages", |
}, | ||||
{ | ||||
pattern:"detail", // Detail view | ||||
name:"detail", | ||||
view:"DetailView", | ||||
} | ||||
] | ||||
} |
On click of the event in Master, I am passing the context as below:
var router = sap.ui.core.UIComponent.getRouterFor(this);
var oBindingContext = evt.getSource().getBindingContext();
this.name = oBindingContext.getProperty("firstName");
router.navTo("detail", oBindingContext);
}
The context is coming up properly in Master while debugging.
However, in Detail View controller, I have following code in onInit function:
onInit: function() { | ||
var oRouter = sap.ui.core.UIComponent.getRouterFor(this); |
oRouter.attachRouteMatched(function(oEvent) {
if (oEvent.getParameter("name") !== "detail") {
return;
}
oContext = oEvent.getParameter("arguments");
}, this);
}, |
However, there is no context I am getting. My question is:
1) How I can pass the selected context to the detail view.
2) If I pass some other paramter say id : 5, I am getting that in the arguments parameter, however, for context it is not working
3) Is there any other way of passing the context in Maste-Detail scenario. I have checked so many forums, blogs, however ,I am not able to find anything specific for context.
Thanks!
Abhi