on 12-23-2016 6:12 AM
Dear gurus
I hope you are doing well
Currently i'm trying to bind a filtered data to a list control in xml view in the oninit event of the controller the odata service url is like this
http://mikmo.mylocalhost.com/MIKMOWCFDataService.svc/view_VendorGroup?$filter=VendorID%20eq%201
i used the code below
var myList = this.getView().byId("lstVendorGroups");
var sListURI = "http://mikmo.mylocalhost.com/MIKMOWCFDataService.svc";
var oListModel = new sap.ui.model.odata.ODataModel(sListURI, false);
var oListModelJson = new sap.ui.model.json.JSONModel();
oListModel.oHeaders = {
"DataServiceVersion": "2.0",
"MaxDataServiceVersion": "2.0"
};
oListModel.read("/view_VendorGroup", null, ["vendorID=" + window.VendorID], null, function(oData, oResponse) {
oListModel.setData(oData);
oListModel.loadData(oData);
}, null);
oListModelJson.attachRequestCompleted(function(oEvent) {
//How to bind the list in here
});
myList.setModel(oListModel, "VendorGroups");
and here is the list xml
<List growing="true" growingThreshold="100" headerText="{i18n>businessareas}" id="lstVendorGroups"
items="{VendorGroups>/view_VendorGroup}">
<items>
<!--<ObjectListItem title="{VendorGroups>GroupName}" type="Active" press=".onItemSelected" />-->
<StandardListItem id="stListItem" title="{VendorGroups>GroupName}"/>
</items>
</List>
Can anyone give me a hint on how to bind the data as the code i wrote is not running
Thanks in advance
Hi Karim,
Please try this..
var sListURI = "http://mikmo.mylocalhost.com/MIKMOWCFDataService.svc";
var oListModel = new sap.ui.model.odata.ODataModel(sListURI, false);
var oListModelJson = new sap.ui.model.json.JSONModel();
oListModel.oHeaders = {
"DataServiceVersion": "2.0",
"MaxDataServiceVersion": "2.0"
};
oListModel.read("/view_VendorGroup", null, ["vendorID=" + window.VendorID], null,
function(oData, oResponse) {
var modelData=[];
for(var i = 0; i < oData.results.length; i++) {
modelData.push(oData.results[i]);
}
oListModelJson.setData(modelData);
}
);
this.getView().setModel(oListModelJson, "VendorGroups");
<List growing="true" growingThreshold="100" headerText="{i18n>businessareas}" id="lstVendorGroups"
items="{VendorGroups>/}">
<items>
<ObjectListItem title="{VendorGroups>GroupName}" type="Active" press="onItemSelected" />
</items>
</List>
Best Regards,
Amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
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.