on 10-16-2016 5:40 PM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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();
console.log(myView);
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();
myJson.loadData(myURL);
myJson.attachRequestSent(function(){
//alert("Sent!");
});
myJson.attachRequestFailed(function(){
//alert("Failed!");
});
myJson.attachRequestCompleted(function(){
window.VendorID = myJson.getProperty("/d/0/VendorID");
//alert(window.VendorID);
if (window.VendorID === null || window.VendorID === undefined) {
sap.m.MessageToast.show("The password id incorrect");
}
});
myView.setModel(myJson);
}
@Partha Sarathi kindly check the code if it worked for you
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
oModel.read("/tbl_Vendors", {filters: aFilter
,success:function(oData,resonse){
//you should be able to get it from oData
}});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
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.