cancel
Showing results for 
Search instead for 
Did you mean: 

Update Table sapui5

naotoxxx
Participant
0 Kudos

I have next issue: i populate my table propertly with one odata call , no problem so far, but i have one butto that make a new request but with diferent date but when i preed nothing happends , testing i found that problem is date i remove them and works fine but i need those data i try to update my table before start to populate with the odata buy i doesn't work

i tried this: (this is the botton that call the odata and should update the table)

nextActivities : function () {
				var newdata = oModel.getData();
				for(var i =0;i<newdata.length;i++)
					{
					 newdata[i].CliNombre ="",
					 newdata[i].Vhvin ="",
					 newdata[i].DbmLicext ="",
					 newdata[i].Esp_servicio ="",
					 newdata[i].timestamp =""
					
					}
				
				
			
				oModel.setData(newdata);
				oModel.refresh()
				
				
	    		var asesor = this.getView().byId("asesortxt_encabezado").getText(asesor);
	    		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);
	    			 }
	            });
	    	
	    		MessageToast.show(asesor);
	    	}

after push the botton:

still the same screen. Now look if i take off thos columns

the first screen the same , after push the button

maybe it's be cause the date and time have formatters? in my console i got "Cannot read property 'toString' of null"

<Text text="{
											path: 'timestamp',
											formatter: '.formatter.fecha_f'
													}" />
										<Text text="{
											path: 'timestamp',
											formatter: '.formatter.hora_f'
										}" />



and this is the formatter:<br><br>sap.ui.define([], function() {
	"use strict";
	
	return {
		fecha_f : function (sTimestamp){
			// Pasamos la fecha a una variable
			var sResult_f = sTimestamp;
			// Paso variable a String para poder manejar
			sResult_f = sResult_f.toString();
			
			var fecha = sResult_f.substr(6,2)+ "-" +
						sResult_f.substr(4,2)+ "-" +
						sResult_f.substr(0,4);
			
			return fecha; // Ahora en el controlador de la vista lo cargamos como una dependencia
		},
		
		hora_f : function(sTimestamp) {
			// Pasamos la fecha a una variable
			var sResult_f = sTimestamp;
			// Paso variable a String para poder manejar
			sResult_f = sResult_f.toString();
			var hora = sResult_f.substr(8,2) + ":" + sResult_f.substr(10,2);
			
			return hora;
		}
	}
	
});

Accepted Solutions (0)

Answers (0)