Hi,
I have an xsjs service querying the database and returning the sum of fields in an xsjs format i.e. {"0":{"SUM":"26710"}.
Now,
I want to display this data to the frontend text field. But I am not getting how exactly to bind this service. Below are my view and controllers:
view.js :
createContent : function(oController) {
var mlayout = new sap.ui.commons.layout.MatrixLayout({width:"auto"});
var lblName = new sap.ui.commons.Label();
lblName.setText(" Enter the Table Name:");
var name = new sap.ui.commons.TextField("TBName");
var result = new sap.ui.commons.TextField("result");
var submitButton = new sap.ui.commons.Button("btnSubmit");
submitButton.setText("Submit");
mlayout.createRow(lblName, name, submitButton, result);
name.attachEvent("getData", function(mEvent){oController.passData(mEvent); });
debugger;
return mlayout;
}
Controller.js :
sap.ui.controller("tool.getTB", {
passData : function (mEvent) {
var url1 = window.location.origin + "/test/services/getTable.xsjs?tbName="+tbName
$.ajax({
url :url1,
type : "GET",
contentType : "application/json;charset=utf-8",
dataType : "json",
success: this.onGetData,
error: this.onErrorCall });
} ,
onGetData : function(mt){
var mResult = sap.ui.getCore().byId("result");
},
onErrorCall: function(jqXHR, textStatus, errorThrown){
sap.ui.commons.MessageBox.show(jqXHR.responseText,
"ERROR",
"Error in calling Service" );
return;
}
});
Thanks,
Maneesha Sharma