2017-02-10 13 views
2

Ui5 doc提供了一個例子,過濾器列表結合或者與AND或OR:如何將兩個sap.ui.model.Filter與不同的運算符連接起來?

new sap.ui.model.Filter({ 
    filters: [...], 
    and: true|false 
}) 

我有兩個濾波器陣列是用串聯OR,如何連接這兩個陣列ALL?是這樣的:

PRODUCTS $跳過= 0 & $頂= 20 & $濾波器=(substringof( '單程',ID)或 substringof( '單程',類型) substringof( 'A',名稱)或方向EQ 'A'

下面是我的代碼:

oTableSearchState1 = [new Filter(filterArray1, false)] //OR 
oTableSearchState2 = [new Filter(filterArray2, false)] //OR 
oTable.getBinding("items").filter(oTableSearchState1, "Application"); 

(我試過new Filter(filterArray1.concat(filterArray2), false);oTable.getBinding("items").filter(oTableSearchState1, "Application").filter(oTableSearchState2, "Application"),顯然它們不工作。)

回答

1

對於需要執行這些複雜操作的情況,可以使用嵌套過濾。您可以使用Filter中的Filter來執行此類操作。

這是基於你的問題的樣本篩選:

var oFilter = new Filter({ 
      filters: [ 
       new Filter({ 
        filters:[ 
         new Filter("ID", FilterOperator.Contains, "One way"), 
         new Filter("Type", FilterOperator.Contains, "One way") 
        ], 
        and : false 
       }), 
       new Filter({ 
        filters:[ 
         new Filter("Name", FilterOperator.Contains, 'A'), 
         new Filter("Direction", FilterOperator.EQ, "A") 
        ], 
        and : false 
       }) 
      ], 
      and: true 
     }); 
相關問題