Filter on more than one column

久未见 提交于 2019-12-07 12:03:45

问题


I have a table that I can filter from one column:

  handleSearch: function(oEvent) {
                var sValue = oEvent.getParameter("value");
                var oFilter = new sap.ui.model.Filter("RAG_SOC_1", sap.ui.model.FilterOperator.Contains, sValue);
                var oBinding = oEvent.getSource().getBinding("items");
                oBinding.filter([oFilter]);
          },

How can I filter from more columns?

For example if I have the columns A, B, C and D, if I write "hello" in the search bar, I want all results that have in fields A or B or C or D the word "hello".


回答1:


Please see the following code:

var oFilter1 = new sap.ui.model.Filter("A", sap.ui.model.FilterOperator.Contains, sValue);
var oFilter2 = new sap.ui.model.Filter("B", sap.ui.model.FilterOperator.Contains, sValue);
var oFilter3 = new sap.ui.model.Filter("C", sap.ui.model.FilterOperator.Contains, sValue);
var oFilter4 = new sap.ui.model.Filter("D", sap.ui.model.FilterOperator.Contains, sValue);
var allFilter = new sap.ui.model.Filter([oFilter1,oFilter2,oFilter3,oFilter4]); 
var oBinding = oEvent.getSource().getBinding("items");
oBinding.filter(allFilter);

See documentation:

new sap.ui.model.Filter(aFilters, bAnd);

aFilters is an array of other instances of sap.ui.model.Filter. If bAnd is set all filters within the filter will be ANDed else they will be ORed.



来源:https://stackoverflow.com/questions/25200955/filter-on-more-than-one-column

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!