on 01-31-2015 5:10 PM
Hi everyone,
As you see in screen shot I have attached in this discussion, I'm trying to fetch data from detail entity set of odata by passing input to it dynamically through master view. In my case the input is BOM number("00000026" as shown in screen shot). I have created a table in my detail.view.xml and trying to do filter & binding in detail.controller.js
when I run follow url in browser it shows expected output in xml format.
http://<host>:<port>/sap/opu/odata/SAP/ZPPBOM_ODATA_SRV/DetailppSet/?$filter= Stlnr eq '00000026'
And when I run project using following code, it neither show any error in consol nor it shows any output in table.
In detail.controller.js there is a variable 'Bomnumber' in which I'm able to get BOM number dynamically from master view.
Please check following xml and js files.
Looking forward for helpful reply.
Regards,
Jagrut Patil.
Detail.view.xml
<Table id="detail1" >
<headerToolbar>
<Toolbar>
<Label text="BOM number"></Label>
</Toolbar>
</headerToolbar>
<columns>
<Column width="12em">
<Text text="Item number" />
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="Item Category" />
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="BOM component" />
</Column>
<Column minScreenWidth="Tablet" demandPopin="true" hAlign="Right">
<Text text="Quantity" />
</Column>
<Column minScreenWidth="Tablet" demandPopin="true" hAlign="Center">
<Text text="Unit of measure" />
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<ObjectIdentifier
text="{Posnr}" />
<Text text="{Postp}" />
<Text text="{Idnrk}" />
<Text text="{Menge}" />
<Text text="{Meins}" />
</cells>
</ColumnListItem>
</items>
</Table>
Detail.controller.js
onInit : function() {
var bus = sap.ui.getCore().getEventBus();
bus.subscribe("app", "RefreshDetail", this._refresh, this);
},
_refresh : function(channelId, eventId, data) {
var Bomnumber = data.Bomnumber;
this.getView().byId("bomnumber").getValue(Bomnumber);
var filter = (new sap.ui.model.Filter("Stlnr",
sap.ui.model.FilterOperator.EQ, Bomnumber));
var oModel = new sap.ui.model.odata.ODataModel(
"/sap/opu/odata/SAP/ZPPBOM_ODATA_SRV",
true);
oModel.read("/DetailppSet/?$filter=",filter);
var oTable = new sap.m.Table("detail1");
oTable.setModel(oModel);
},
your code is bad.
1) create odata model in onInit
2) bind table in onInit
3) in _refresh do filter on list binding from table
this.byId("detail1").getBinding("items").filter(filter)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Maksim,
I have another doubt. I'm developing another app, just for practise. The app is for user management.
Means for create, update & delete user. So Page 1 shows total list of user in table. When we click on 'Create' button it navigate to Page 2. In page 2 when we click on 'Save' it saves the data and navigate back to Page 1. So here I'm getting problem, when I click on Save it should refresh Page 1 automatically but in my app I have to reload page manually to see the created data.
I tried model.refresh(); after mode.create("/Masterset", oEntry, null, Function(success), Function(error)); But its not refreshing data of table in Page 1
So please help me for that.
Regards,
Jagrut.
Hi Jagrut,
Hope this helps - JS Bin - Collaborative JavaScript Debugging</title> <link rel="alternate" type=&q...
In this example i used JSON model it can be replaced with a oData model.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Jagrut,
try apending the filter as a string such as : $filter=Column eq Value.
i Am not sure if the oModel.read(path, filter) function will work like that, check out in the API what other parameters you can pass to the omodel.read function you would need to pass if you want to go with objects.
hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.