2015-06-03 44 views
0

我需要知道的唯一事情是,如果我可以爲ComboBox中的項目創建值,那麼我認爲我將能夠完成手頭的任務。我會做這樣的事情:如何使用組合框過濾表格?

var oItem1 = new sap.ui.core.ListItem("lab", { 
    text: 'Lab', 
    value: 'Lab' 
}); 

var oItem2 = new sap.ui.core.ListItem("boxer", { 
    text: 'Boxer', 
    value: 'Boxer' 
}); 

然後我會用一個按鈕,通過該表進行過濾,像這樣:

var oButton = new sap.ui.commons.Button({ 
    text: "find", 
    styled: false, 
    press: function() { 
     var oFilter1 = new sap.ui.model.Filter("typeOfDog", sap.ui.model.FilterOperator.Contains, oItem1.getValue()); 
     var oFilter2 = new sap.ui.model.Filter("typeOfDog", sap.ui.model.FilterOperator.Contains, oItem2.getValue()); 
     var allFilter = new sap.ui.model.Filter([oFilter1, oFilter2], false); 
     oTable.getBinding("rows").filter(allFilter); 
    } 
}).addStyleClass("searchButton").placeAt("search"); 

然而,這是行不通的。我假設這是因爲我無法爲ListItem創建值。如果可以,我該怎麼做?

編輯:有沒有辦法做類似CheckBox的方法,等價的方法.getChecked()?

回答

1

我想通了。我用了一個DropdownBox來代替,而用下面的代碼:

oDropDown.attachChange(function() { oTable.getBinding("rows").filter(new sap.ui.model.Filter("payment", sap.ui.model.FilterOperator.EQ, oDropDown.getValue())); }); 
0

我認爲你可以使用FacetFilters也.FacetFilter由FacetFilterList的,這些都是在facetfilter表中選擇將獲得filterd值在table.Based列。