Reputation: 1581
I have a sapui5 table and I have called a scroll function on the tables scrollbar. It works only when I use setTimeout
. I am assuming that's because the data in the table loads slightly after the actually table loads.
Here's the code I have:
setTimeout(function () {
var lastScroll = 0;
$("#__xmlview0--players-vsb-sb").scroll(function () {
var st = $(this).scrollTop();
if (st > lastScroll) {
console.log("scrolling down");
} else {
console.log("scrolling up");
}
lastScroll = st;
});
}, 900);
I have tried to use the onAfterRendering
function as an alternative but I can't get that to work. Does anyone know an alternative to setTimeout
?
Here is my JSBin.
Upvotes: 4
Views: 5022
Reputation: 11
If this is a sap.m.Table you can use the updateFinished Event from sap.m.ListBase see :
OpenUI5 SDK - Demo Kit v2.0
updateFinished(oControlEvent)
This event is called after items binding and afterwards related DOM is updated.
Parameters:
{sap.ui.base.Event} oControlEvent
{sap.ui.base.EventProvider} oControlEvent.getSource
{object} oControlEvent.getParameters
{string} oControlEvent.getParameters.reason The reason of update. Possible values are "Binding", "Filter", "Sort", "Growing", "Change", "Refresh", "Context"
{int} oControlEvent.getParameters.actual Actual number of items.
{int} oControlEvent.getParameters.total The total count of bound items. This parameter can be used if "growing" feature is enabled.
Since:
1.16.3
Upvotes: 1