on 07-08-2016 6:14 PM
Hi,
I created a Master-Detail split app with Plant as a ComboBox in the Master View. I am able to bind the odata dataset for the Plant in Mater View but when I select the plant I want to show related storage locations in a table in the Detail View. In order to fetch the storage locations I created an association and the url looks something like this when I pick the plant '1001' /../sap/ou/odata/sap/Z_PLANT_SLOC_SRV/PlantSet('1001')/PlantToSLoc and resultant dataset is 'SLocSet'. I build the routes in the component.js and I am using xml view with sap.m. library.
I am not seeing any data binding in the detail view table not sure how to pass the association name in the route pattern. Currently my code in the
Master View
rowChange: function(evt){
var contect = evt.getParameter("selectedItem").getBindingContext("plantModel")+" ";
var path = context.split("/")[1];
this._oRouter.navTo("Detail",{contextPath:path});
}
**In the path variable this is what I have "PlantSet('1001')"
Component.JS
routes:[
subroutes: [
pattern: "{contextPath}",
name: "Detail",
view: "DetailView",
]
init: function() {
oModel instantiation....
}
DetailView.view.xml
<Table id="itTabSloc" items="{plantModel>/SLocSet}'
<columns>
<Column>
<Text text="Plant"/>
</Column>
<Column>
<Text text="Sloc"/>
</Column>
<Column>
<Text text="Desc"/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{plantModel>Werks}"></Text>
<Text text="{plantModel>Lgort}"></Text>
<Text text="{plantModel>Lgort}"></Text>
</cells>
</ColumnListItem>
</items>
DetailView.view.JS
onInit: function() {
this._oRouter = sap.ui.core.UIComponent.getRouterFor(this);
this._oRouter.attachRoutePatternMatched(this._handleRouteMatched,this);
},
_handleRouteMatched: function(oEvent) {
var oParameters = oEvent.getParameter("name");
if(oParameters!="Detail"){ return;}
var path = oEvent.getParameter("arguments").contextPath;
path= "/"+path;
this.getView().bindElement(path);
this.getView().byId("TabId").bindRows(path+'/PlantToSLoc');
}
Thanks
Hi Ramesh,
Two things, I see a problem:
1. Typo in the rowChange event: contect should be 'context'
var context = evt.getParameter("selectedItem").getBindingContext("plantModel")+" ";
var path = context.split("/")[1];
this._oRouter.navTo("Detail",{contextPath:path});
2. You're using a model name. When you use bindElement method, you have to mention model name as well, something like this:
onInit: function() {
this._oRouter = sap.ui.core.UIComponent.getRouterFor(this);
this._oRouter.attachRoutePatternMatched(this._handleRouteMatched,this);
},
_handleRouteMatched: function(oEvent) {
var oParameters = oEvent.getParameter("name");
if(oParameters!="Detail"){ return;}
var path = oEvent.getParameter("arguments").contextPath;
path= "/"+path;
this.getView().bindElement({
path: path,
model: "plantModel"
});
// this.getView().byId("TabId").bindRows(path+'/PlantToSLoc');
}
Here is a sample using Northwind OData service: Plunker
Regards,
Sai.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sai,
Thanks for your response appreciate your time I am using firefox browser and I tried to implement pretty much in line with the sample you provided but still not getting the binding to the table in the detail view. I am attaching the files if you can visually see any thing I am doing wrong please let me know.
User | Count |
---|---|
84 | |
9 | |
9 | |
8 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.