12
Views
2
Comments
Solved
On Scroll Ending for tables
Application Type
Reactive

Hello everyone,

When working with lists, there is an "onscroll ending" event. However for tables it does not exist. How can I do the onscroll ending for tables?

Thanks in advance

Rank: #93
Solution

Hello Manuel,

Hope you're doing well.

Unfortunately, there is no On Scroll Ending event by default for Tables in OutSystems.

Are you referring to a scrollable table, correct? I believe this only makes sense if you have a scrollable table.


What you can do is simulate a similar behavior for that event using JavaScript, based on scroll event. For example, consider to place the following JavaScript code in your OnReady event in order to add a listener that will be triggered for each scroll of the table. It will calculate the current position and compare it with the total height of the surrounding element to check if you reached the bottom:

document.getElementById("Element").addEventListener("scroll", function() {
    
    var scrollTop = document.getElementById("Element").scrollTop;
    var scrollHeight = document.getElementById("Element").scrollHeight;
    var offsetHeight = document.getElementById("Element").offsetHeight;
    
    //check if the scroll reached the bottom
    if (offsetHeight + scrollTop >= scrollHeight)
    {
        $actions.OnScrollEnding();
    }
});

where Element is the Container (div) surrounding your Table and OnScrollEnding is the handler (screen action) that you want to execute.

Please refer to attached OML file :)

Hope that this helps you!


Kind regards,

Rui Barradas

OnScrollEndingTest.oml

Rank: #14288

Thank you!