Skip to Content
0
Former Member
Aug 03, 2016 at 11:12 AM

Perform action after table data is available

106 Views

Hi,

in my xml view i dynamically set the model. The data is delivered from a calculation view. I know want to iterate over the delivered rows and check a condition (sum of values in a column is bigger than certain value).

I attached a function to the "RequestCompleted" event, but it seems, the table is not filled with data yet, because i get only empty strings out of the cells.

_onRouteMatched : function(oEvent) {
            var aFromTo = oEvent.getParameter("arguments").request.split("&");

            // storing in global variables
            iId = aFromTo[0];
            dFrom = new Date(aFromTo[1]);
            dTo = new Date(aFromTo[2]);

            var sPath = "/input(Beginn=datetime'" + this.convertDateToEDM(dFrom) + "',Ende=datetime'"
                    + this.convertDateToEDM(dTo) + "')/Results";

            var oBindingInfo = {
                path : sPath
            };

            this.getView().byId("TableId").bindRows(oBindingInfo);
           
            var that = this;
            this.getView().byId("TableId").getModel().attachRequestCompleted(function() {
                var oTable = that.byId("TableId");
                var oRows = oTable.getRows();
               
                if (oRows.length == 0) {
                    return;
                }
               
                var dPerformance = 0.0;
                for (var i = 0; i < oRows.length; i++) {
                    var oCells = oRows[i].getCells();
                    console.log(oCells);
                    var s = oCells[3].getText();
                    var x = parseFloat(s)
                    dPerformance += x;
                }   
});
},