I need to filter the odata service with multiple filter items and bind result set to table. This whole action will take place on click of search button. Below is my Onsearch event code which is failing in read function and not returning a result and not able to bind it to table. Can anyone please me help on this?
Controller Code
onFinalFilter: function (oEvent) {
debugger;
var oPlant = this.getView().byId("plant").getValue();
var oName1 = this.getView().byId("name1").getValue();
var oName2 = this.getView().byId("name2").getValue();
var oState = this.getView().byId("State").getValue();
var oCity = this.getView().byId("city").getValue();
var oZip = this.getView().byId("zip").getValue();
var oCompanyCode = this.getView().byId("companyCode").getValue();
var p = new Filter("WERKS", FilterOperator.EQ, oPlant);
var n1 = new Filter("NAME1", FilterOperator.EQ, oName1);
var n2 = new Filter("NAME2", FilterOperator.EQ, oName2);
var s = new Filter("STATE", FilterOperator.EQ, oState);
var c = new Filter("CITY", FilterOperator.EQ, oCity);
var cc = new Filter("BUKRS", FilterOperator.EQ, oCompanyCode);
var zip = new Filter("PSTCODE", FilterOperator.EQ, oZip);
var finalFilter = new Filter({filters:[p,n1,n2,c,s,zip,cc], and:true});
var oModel = new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/sap/ZSM_PLANTSRCH_SRV/"); sap.ui.getCore().setModel(oModel);
var oModel2 = new sap.ui.model.json.JSONModel();
oModel.read("/PLANTSRCHSet", {
filters: finalFilter,
success: function (oData, oResponse)
{ var data = oData; oModel2.setData(data); this.getView().byId("table1").setModel(oModel2, "key2"); },
error: function (oError) { //alert("error"); } });
}