$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: false, vro: false, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); Skip to Content

SAPUI5 single entity binding while using filters

Oct 16, 2016 at 04:40 PM


avatar image

Dear Gurus

i created the below OData service that contains two entities

Then i created the app i started with the first view and the controller then in it i wrote the following code

onLogin: function(){
		var sURI = "proxy/http/localhost:9999/MIKMOWCFDataService.svc/";
		var oModel = new sap.ui.model.odata.ODataModel(sURI, false);
		oModel.oHeaders = {
			"DataServiceVersion": "2.0",
			"MaxDataServiceVersion": "2.0"
		var aFilter = [];		
		aFilter.push(new sap.ui.model.Filter("VendorEmail", sap.ui.model.FilterOperator.EQ, this.getView().byId("txtUserName").getValue()));
		aFilter.push(new sap.ui.model.Filter("VendorPassword", sap.ui.model.FilterOperator.EQ,this.getView().byId("txtPassword").getValue() ));
		oModel.read("/tbl_Vendors", {
			filters : aFilter

What i'm trying to achieve from the code is to get the user id after he submits his email and password i managed to return the correct row from the DB but after that i was not able to read the ID property from the returned data it's only done through using list and press on the list item to fire another event and then read the ID which is not reasonable in the giving example can any one help me on how to read the property directly from the model Thanks in advance

6kdlh.jpg (149.2 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Jun Wu Oct 17, 2016 at 01:07 AM
oModel.read("/tbl_Vendors", {filters: aFilter
//you should be able to get it from oData

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

Dear Jun Wu

Thanks for your reply

I tried your code and added the following lines

var bUser = oModel.getProperty("/VendorID");

but it returned undefined

and one more thing how to pass the oData and the response parameters

Thanks in advance

Jun Wu Oct 17, 2016 at 01:48 PM

you don't have to do anything, that is callback function, "they" will fill the odata for u.

put a breakpoint in that method, and put oData in the console, you will see

10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Oct 17, 2016 at 06:48 PM

I have also same kind of requirement.

@Karim: Please let me know if you could able to get the filtered data.

@Jun Wu: I can see all the entries in console in oData. Not the filtered one.

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

Dear Jun Wu

Thanks for your caring but it seems that i have a problem in my code that doesn't retrieve the data but i manage to use another approach to get the data i used the below code

onLogin: function(){
		var myView = this.getView();
		var myURL = "proxy/http/localhost:9999/MIKMOWCFDataService.svc/tbl_Vendors/?$filter=VendorEmail eq '"+this.getView().byId("txtUserName").getValue()+"' and VendorPassword eq '"+this.getView().byId("txtPassword").getValue()+"'";
		var myJson = new sap.ui.model.json.JSONModel();
			window.VendorID = myJson.getProperty("/d/0/VendorID");
			if (window.VendorID === null || window.VendorID === undefined) {
				sap.m.MessageToast.show("The password id incorrect");

@Partha Sarathi kindly check the code if it worked for you


you have to check your backend code to see if filtering is done properly there.