筛选器仅筛选父级而不筛选树表中的子级

时间:2019-07-03 09:36:05

标签: sapui5

我有一个嵌套结构最高到1级的树表。当我在该表上过滤数据时,它会完全删除嵌套的子结构,只给我包含父数据的行。

filterTable: function (aCurrentFilterValues) {
   var filters = this.getFilters(aCurrentFilterValues);
   this.getTableItems().filter(filters, true);
}

getTableItems: function () {
   return this.getTable().getBinding("rows");
}
getFilters: function (aCurrentFilterValues) {
            var newFilter = [];
            var filter1 = "",
                filters1 = [],
                filter2 = "",
                filters3 = [],
                filter3 = "",
                filter4 = "";
            aCurrentFilterValues[0].forEach(function (selections) {
                filters1.push(new sap.ui.model.Filter("pan", sap.ui.model.FilterOperator.Contains, selections));
            });
            if (filters1.length > 0) {
                filter1 = new sap.ui.model.Filter(filters1, false);
            } else {
                filter1 = new sap.ui.model.Filter("pan", sap.ui.model.FilterOperator.NE, "All");
            }
            if (aCurrentFilterValues[1] === 'All') {
                filter2 = new sap.ui.model.Filter("createdOn", sap.ui.model.FilterOperator.NE, aCurrentFilterValues[1]);
            } else {
                filter2 = new sap.ui.model.Filter("createdOn", sap.ui.model.FilterOperator.EQ, aCurrentFilterValues[1]);
            }
            aCurrentFilterValues[2].forEach(function (selections) {
                filters3.push(new sap.ui.model.Filter("status", sap.ui.model.FilterOperator.Contains, selections));
            });
            if (filters3.length > 0) {
                filter3 = new sap.ui.model.Filter(filters3, false);
            } else {
                filter3 = new sap.ui.model.Filter("date", sap.ui.model.FilterOperator.NE, "All");
            }
            if (aCurrentFilterValues[3] === 'All') {
                filter4 = new sap.ui.model.Filter("date", sap.ui.model.FilterOperator.NE, aCurrentFilterValues[3]);
            } else {
                filter4 = new sap.ui.model.Filter("date", sap.ui.model.FilterOperator.EQ, aCurrentFilterValues[3]);
            }
            newFilter = [new sap.ui.model.Filter([
                filter1,
                filter2,
                filter3,
                filter4
            ], true)];
            return newFilter;
        }

如何通过不消除嵌套数据来过滤表中的数据

0 个答案:

没有答案