Skip to Content
0

List binding with filtered data in XML view

Dec 23, 2016 at 06:12 AM

75

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Amit Singh Dec 23, 2016 at 07:28 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks Amit for your reply

But when i used your code it throws an error that there is no method for Length

Thanks again for your consideration

0