Skip to Content
0
Jan 23, 2019 at 10:32 AM

Filter Data from Backend(OData read Call) based on Input provide on UI5 screen

265 Views

I tried to filter the Data and bind to the table through JSON model however i am encountering an error

"Cannot read property 'replace' of undefined"

Could any one help to resolve the filter scenario.

Below is the code used

	var oFilter, aFilter;
			oFilter = [];


			if (!oInput.documentDate) {
				oFilter.push(new Filter("DocumenDate", "EQ", "datetime'" + oInput.documentDate + "T00:00:00'"));
			}


			if (oInput.materialNum) {
				oFilter.push(new Filter("MaterialNumber", "EQ", oInput.materialNum));
			}


			if (oInput.pONum) {
				oFilter.push(new Filter("PONumber", "EQ", oInput.pONum));
			}


			if (oInput.shippingDate) {
				oFilter.push(new Filter("ShippingDate", "EQ", "datetime'" + oInput.shippingDate + "T00:00:00'"));
			}
			if (oInput.pOType) {
				oFilter.push(new Filter("POType", "EQ", oInput.pOType));
			}


			if (oInput.supplierCode) {
				oFilter.push(new Filter("SupplierCode", "EQ", oInput.supplierCode));
			}


			if (oInput.supplierMatNum) {
				oFilter.push(new Filter("SupplierMatNum", "EQ", oInput.supplierMatNum));
			}


			if (oInput.deliveryStatus) {
				oFilter.push(new Filter("DeliveryStatus", "EQ", oInput.deliveryStatus));
			}


			if (oInput.dONum) {
				oFilter.push(new Filter("DONumber", "EQ", oInput.dONum));
			}


			var oMainFilter = new Filter({
				filters: oFilter,
				and: false
			});
			aFilter = [oMainFilter];


			var that = this;
			this._oModel.read("/ENTITYSet", {
				filters: [aFilter],
				success: function (oData, response) {
					that._oViewModel.setData({results : oData.results});
					debugger;
					oTable.setModel(that._oViewModel, "tableModel");
				},
				error: function (oError) {}


			})