Skip to Content

SAPUI5 single entity binding while using filters

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
		});
		sap.ui.getCore().setModel(oModel,"vendors");		
	}

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)
Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Posted on Oct 17, 2016 at 01:07 AM
    oModel.read("/tbl_Vendors", {filters: aFilter
    		,success:function(oData,resonse){
    //you should be able to get it from oData
    
    
    
    
    }});
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on 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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on 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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.