Skip to Content
avatar image
Former Member

oList is changed after applying Filter

Hi Team,

I am facing a weird issue. I have a table with JSON model and data is retrieveing during Init of the application. I have a custom filter for the table. When I enter the value it is filtering the values properly for the first time. on the second time when I do it, it always filters based on the filtered value and not the original model.

Upon checking thethis.getView().byId(tabname).getBinding("items"), I found that oList is getting refreshed with filtered values.

Could you please provide some hints on this behaviour and how to stop it?

The logic to filter is working for other table in the same application. Just one table is causing issue...

My code to filter.

var oFilter = null ; 

if (fValue) 

{ oFilter = new sap.ui.model.Filter("ColumnA", sap.ui.model.FilterOperator.Contains, fValue); } 

var binding = this.getView().byId("Table1").getBinding("items"); 

binding.filter(oFilter,sap.ui.model.FilterType.Application); 

binding.refresh(true);
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 01, 2017 at 12:45 AM

    Issue resolved. The problem was with setting the count of the icontabfilter. When setcount method is used to show the updated result, it creates the above issue. Removed the code and coded differently to show the filtered result count.

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 31, 2017 at 05:56 PM

    why are you using filtertype as 'Application'?

    change filter type from 'Application' to 'Control', it should work fine.

    binding.filter(oFilter, sap.ui.model.FilterType.Control);

    Application filter: When a set of entries is filtered using Application filter then the filter stays on until the application is terminated or closed. Eg: For a list of 100 items application filter is applied....assuming this results output of 80 entries. Now another application filter or second time filter is applied....in this case previous application filter and the current application filter are applied which results in applying new application filter on 80 entries.

    Control Filter: Everytime a new control filter is applied...then previous control filter is over written. Considering the previous example on filtering first time we have 80 items....then on re-applying a different filter system clears of old filters and applies the current filter only......this results in applying current filter on 100 items.

    Add comment
    10|10000 characters needed characters exceeded