Scroll to a selected item in a listview

0
Hello everyone,   I have a dashboard in Mendix with two list views with scrollbars (overflow: scroll) on the very left. Further to the right there are data views that depend on the selected object in one of the lists. Because a data view cannot listen to multiple widgets, I call up the page again every time I click on an entry in the list and pass the selected element as a parameter. But then the list jumps back to the top. How can I ensure that the selected element is scrolled to when the page is called up again?   Thanks in advance!     Edit: Is it also possible to highlight the selected element after a new page load? At the moment I'm changing the background for the $currentObject, because the highlighting also disappears when the page is reloaded.
asked
2 answers
0

You can use a JavaScript action to store the scroll position and restore it when the page reloads. Store Scroll Position on Click: 

var listView = document.getElementById('your-list-view-id');

var scrollPosition = listView.scrollTop;

localStorage.setItem('listViewScrollPosition', scrollPosition);

 

  • Go to the page where you have the list view.
  • Add a Javascript action to the page and paste the above code into the action.
  • Trigger the JavaScript action on page load (using a "On Page Load" microflow or event).
answered
0

You could use a Nanoflow to call the Web Actions ScrollTo action. This will scroll to a specified element on the page. You could also use the SetFocus action to move the browser's focus to a specific element. These are both platform supported features from Mendix.

 

https://docs.mendix.com/appstore/modules/web-actions/

 

Good luck!

answered