Reputation: 1507
Master Details Template
When click on Master[list]
it will navigate to detail page with table data, suppose four column are there and an "Add" Button in the last column.
Now what I want is, on click that "Add" button that row data will bind direct in cart view.
I tried using local storage, but how to call local stored data in cart view.
Cart view is on Master page with icon
On click cart icon view page is this
onPress: function(evt){
localStorage.setItem('user', JSON.stringify({
a : evt.oSource.oParent.mAggregations.cells[0].mProperties.src,
b : evt.oSource.oParent.mAggregations.cells[1].mProperties.text,
c : evt.oSource.oParent.mAggregations.cells[2].mProperties.text,
d : evt.oSource.oParent.mAggregations.cells[3].mProperties.text
}));
user = JSON.parse(localStorage.getItem('user'));
}
Upvotes: 0
Views: 7537
Reputation: 5532
I am assuming you are in a Component-based application using a UI5 Router and an ODataModel resp. Service.
You could just pass the id of your table entry onto the detail view via routing:
onAddBtnPressed : function(oEv) {
var oRouter = sap.ui.core.UIComponent.getRouterFor(this),
oContext = oEv.getSource().getBindingContext("your-model-name"),
sDetailID = oContext.get("your-id-prop-name");
oRouter.navTo("detail", {
detailID: sDetailID
})
}
from routing.config.routes:
{
"pattern": "detail/{detailID}",
"name": "detail",
"target": "detail"
}
Note: {param}
marks a parameter as mandatory while :param:
is used for an optional parameter.
In your Detail.controller.js register a listener on routePatternMatched and implement it like this:
onRoutePatternMatched: function(oEv) {
var sDetailID = oEv.getParameter("arguments").detailID;
// create binding context on detail view
this.getView().bindElement({
"/YourDetailSet('"+ sDetailID +'")"
model: "your-model-name"
})
// all the bindings in your detail view will no be relative to the above binding context.
}
Upvotes: 0