Skip to Content
avatar image
Former Member

add second filter without removing the existing ones

Hi i have a searchfield with this code behind it:

onSearch : function (oEvent) {
	if (oEvent.getParameters().refreshButtonPressed) {
	    // Search field's 'refresh' button has been pressed.
	    // This is visible if you select any master list item.
	    // In this case no new search is triggered, we only
	    // refresh the list binding.
	} else {
		var andFilter = [];
		var sQuery = oEvent.getParameter("query");			        if (sQuery && sQuery.length > 0) {
		// add filters
		var oTableSearchState = [];
		oTableSearchState = [new Filter("Supplier", FilterOperator.Contains, sQuery),									     new Filter("BusArea", FilterOperator.Contains, sQuery),		     new Filter("CostCenter", FilterOperator.Contains, sQuery),
		     new Filter("FuncArea", FilterOperator.Contains, sQuery)		 ];
		andFilter.push(new Filter(oTableSearchState, false));

And a filter button that should add aditional filters. Something like this:

onSetFilter : function(oEvent) {
	var andFilter = [];
	andFilter.push(new Filter("BusArea", FilterOperator.EQ, "5000"));

But of course the "BusArea" part should be dependent on what filters are selected. It could be more than 1 filter. the _applySearch function looks like this:

_applySearch: function(andFilter) {
	var oViewModel = this.getModel("worklistView");
	this._oTable.getBinding("items").filter(andFilter, true);
	// changes the noDataText of the list in case there are no filter results
	if (andFilter.length !== 0) {
	    oViewModel.setProperty("/tableNoDataText", this.getResourceBundle().getText("worklistNoDataWithSearchText"));

the problem is that when i add a filter via the filter button, the filters from the searchbar disappear and the other way arround. how can i change my code so that i can add the filters without removing the existing ones?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers