I have a Master-Detail view on SAPUI5, using oData. On the Detail, I have a sap.ui.table.Table
and I want to calculate the sum of each column and place it on a sap.m.Label
, which is placed at the footer of the table.
I am running a function at the busyStateChanged
event of the table, responsible for calculating the sum by adding the values the column cells. The problem is that when the event is triggered, the binding context is not available yet. I have tried placing the code in the _onBindingChange()
method, but even though the binding context is available then, the values from the oData are not visible yet in the sap.m.Input
fields that exist on the table, therefore the sum is calculated wrongly.
As a workaround I have used a Promise
to wait for a few ms before calculating the sums (triggered from the busyStateChanged
event). The code looks like this:
tableAfterRender: function() {
var that = this;
var waitSomeTime = this.sleep(50);
waitSomeTime.then(function() {
that.calcSums();
});
},
sleep: function(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
The problem is that Promises do not work with Internet Explorer. Is there an alternative approach (e.g. an alternative to Promise -preferably not a worker, since it requires a new file from what I have read- or a sap.ui.table.Table
event) to wait for data loading before calculating the sums?
Thank you very much!