I have a List defined in a XML View. I bind the items of the list in the XML View but I want to define the filters in the JavaScript Code because the filters are to complex to define in XML. I create the filters in FilterUtils and now I want to set that array of filters as the filters of the list.
XML View:
<List id="order-List" items="{path: '/OrderSet',filters : ???} inset="false" growingScrollToLoad="true" growing="true" growingThreshold="5">
FilterUtils:
jQuery.sap.declare("de.my.util.FilterUtils");
jQuery.sap.require("sap.ui.model.FilterOperator");
de.my.util.FilterUtils = {
/**
* Returns the filter to request all mobile relevant orders of the current work center
*/
buildFilterServiceOrdersOfCurrentWorkcenter: function () {
var filterMnWkCtr = new sap.ui.model.Filter("MnWkCtr", sap.ui.model.FilterOperator.EQ, de.my.Component.getMetadata().getConfig().myConfig.mnWkCtr);
var filterUserstatus = new sap.ui.model.Filter("Userstatus", sap.ui.model.FilterOperator.EQ, 'ACT');
var filterOrderType = new sap.ui.model.Filter([new sap.ui.model.Filter("OrderType", sap.ui.model.FilterOperator.EQ, 'AS1'), new sap.ui.model.Filter("OrderType", sap.ui.model.FilterOperator.EQ, 'AS2'), new sap.ui.model.Filter("OrderType", sap.ui.model.FilterOperator.EQ, 'AS3'), new sap.ui.model.Filter("OrderType", sap.ui.model.FilterOperator.EQ, 'AS4')], false);
var filterServiceOrders = new sap.ui.model.Filter([filterMnWkCtr, filterUserstatus, filterOrderType], true);
return filterServiceOrders;
}
}