将过滤器传递给odata sapui5

时间:2018-03-19 19:21:03

标签: sapui5

有人知道如何将多个参数传递给odata吗?看起来我这样做了:

        nextActivities : function () {
            var oTableClear = this.getView().byId("tabla");
            oTableClear.destroyItems();
            // Obtenemos la fecha y Asesor
            var fecha = this.byId("lFecha").getText();
            var asesor = this.byId("usuario").getValue();

            var oTable = this.getView().byId("tabla");
            var sURI = "/sap/opu/odata/SAP/ZERP_ACTIVIDADES_SRV";
            var oDataModel = new ODataModel(sURI, true);
            var oModel = new sap.ui.model.json.JSONModel();
            var oFilter = new Filter("Asesor", "EQ", asesor);
            oDataModel.read("/ReservaNextSet", {
                filters: [oFilter],
                success: function(oData, response) {
                var oResults = oData.results;
                oModel.setData(oData.results);
                oTable.setModel(oModel);
                 }


            });
        },

我尝试了这个但是我收到了一个错误:

[new Filter("Asesor", "EQ", asesor),
new Filter("timestamp", "EQ", fecha)];

和这:(有了这个没有错误,但在表中it_filter_select_options没有捕捉任何东西)

var oFilter0 = new Filter("Asesor", "EQ", asesor);
        var oFilter1 = new Filter("timestamp", "EQ", fecha);
        var oFilter = new Filter([oFilter0, oFilter1], false);

                oDataModel.read("/ReservaNextSet", {
                    filters: [oFilter],

并且像这样:

var oFilter , aFilter;

                oFilter = [];
                oFilter.push(new Filter("Asesor", "EQ", asesor));
                oFilter.push(new Filter("timestamp", "EQ", fecha));

                aFilter = new Filter({ filters: oFilter, and: false });

                oDataModel.read("/ReservaNextSet", {
                    filters: [aFilter],
                    success: function(oData, response) {
                    var oResults = oData.results;
                    oModel.setData(oData.results);
                    oTable.setModel(oModel);
                     }

1 个答案:

答案 0 :(得分:0)

这是解决方案:注意过滤器:oFilter not [oFilters]是因为它已经是一个数组             // Llama al odata con el usuario y fecha             nextActivities:function(){                 var oTableClear = this.getView()。byId(" tabla");                 oTableClear.destroyItems();

            // Obtenemos la fecha y Asesor
            var fecha = this.byId("lFecha").getText();
            var asesor = this.byId("usuario").getValue();

            var oTable = this.getView().byId("tabla");
            var sURI = "/sap/opu/odata/SAP/ZERP_ACTIVIDADES_SRV";
            var oDataModel = new ODataModel(sURI, true);
            var oModel = new sap.ui.model.json.JSONModel();

            var oFilter;
            oFilter = [];
            oFilter.push(new Filter("Asesor", "EQ", asesor));
            oFilter.push(new Filter("timestamp", "EQ", fecha));

            oDataModel.read("/ReservaNextSet", {
                filters: oFilter,
                success: function(oData, response) {
                var oResults = oData.results;
                oModel.setData(oData.results);
                oTable.setModel(oModel);
                 }


            });
        },