0
votes

do someone knows how to pass more than one parameter to the odata? look i did this:

        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);
                 }


            });
        },

i tried this but i got an error:

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

and this: (with this theres no error but in the table it_filter_select_options is not catching anything )

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],

and like this:

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

1 Answers

0
votes

This is the solution: pay attention to filters : oFilter not [oFilters] be cause it's already an array // 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);
                 }


            });
        },