cancel
Showing results for 
Search instead for 
Did you mean: 

SAP UI5 table search multiple values with OR condition

vinodkumar_thangavel
Participant
0 Kudos

Hi Experts,

Currently I have an UI table and if I try filtering the table values from my search input using the below code it works fine with AND condition.

Please let me know how to make it work with OR condition .

Thanks ,

Vinodkumar.

var Supplier = this.getView().byId('IDINSupplier').getSelectedItems();
			var Supplierlen = Supplier.length;
			var obj2 = '';
			for (var i = 0; i < Supplierlen; i++) {
				var value = Supplier[i].mProperties.key;
				var oFilter = new sap.ui.model.Filter("SupplierName", sap.ui.model.FilterOperator.EQ, value);
				aFilters.push(oFilter);
			};
			var Parts = this.getView().byId('IDINPart').getSelectedItems();
			var Partslen = Parts.length;
			var obj2 = '';
			for (var i = 0; i < Partslen; i++) {
				var value = Parts[i].mProperties.key;
				var oFilter = new sap.ui.model.Filter("Parts7", sap.ui.model.FilterOperator.EQ, value);
				aFilters.push(oFilter);
			};
           oTable.filter(aFilters, "Application");
abdul_kareem
Explorer

Hello Vinoth

You can try this way for multiple filter.

var filters = [];
var Supplier = this.getView().byId('IDINSupplier').getSelectedItems();
var Parts = this.getView().byId('IDINPart').getSelectedItems();
if (Supplier.length > 0) {
$.each(Supplier, function (i, UIitem) {
filters.push(new sap.ui.model.Filter("SupplierName", sap.ui.model.FilterOperator.EQ, UIitem.getKey()));
});
};
if (Parts.length > 0) {
$.each(Parts, function (i, UIitem) {
filters.push(new sap.ui.model.Filter("Parts7", sap.ui.model.FilterOperator.EQ, UIitem.getKey()));
});
};
this.getView().byId("yourUItableID").getBinding("rows").filter(filters);
vinodkumar_thangavel
Participant
0 Kudos

Hi Abdul,

Thank You,

I tried using the above code still my search result filters only with AND condition its not working for OR condition.

e.g If I try selecting few suppliers & Parts the result is showing only with AND condition but I need the result to be filtered with All selected values from the search.

Accepted Solutions (1)

Accepted Solutions (1)

former_member392818
Participant
0 Kudos

hi, you need to combine the filters into a new one with "and: false", just like below .

new Filter({ filters:[filter_A, filter_B], and: false} );
vinodkumar_thangavel
Participant
0 Kudos

Thank Liu , Your solution worked for me :).

Answers (0)