How to trigger: scroll to end of ListView? - Mendix Forum

How to trigger: scroll to end of ListView?

133701

Dear community,

I am building a messenger into my app. The box to enter a new message is at the bottom of the page. When a new message is added, this shall show up at the very bottom in the discussion thread. I use an ListView to list all messages. However, once the new message is added, the user needs to scroll down to see it appear in the discussion thread.

Is there an option to automatically scroll the ListView to the bottom? Ideally with a microflow statement, that can be triggered once the message is committed.

I have tried the PerfectScrollbar widget (https://appstore.home.mendix.com/link/app/105048/) but could not make it work. Same applies to the "Scroll To Anchor" Widget.

Any help/pointers would be appreciated.

asked
1 answers
0

You can add a HTML snippet with the following JavaScript:

<selectorforyourbutton>.onClick = function() {

var objDiv = <selectorforyourmessagecontainer>;
objDiv.scrollTop = objDiv.scrollHeight;

}

You might need some timeout though to make sure it's only triggered after the message appears.

 

It's not possible to trigger it from your microflow, since there's only limited client-side updates that can be triggered from there (open page, close page, show pop up message, etc...)

answered