# Synchronize multiple tables scroll position

**URL:** <https://forum.inductiveautomation.com/t/synchronize-multiple-tables-scroll-position/98052>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [November 1, 2024, 4:59pm UTC](https://forum.inductiveautomation.com/t/synchronize-multiple-tables-scroll-position/98052 "2024-11-01T16:59:31Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 1, 2024, 7:35pm UTC](https://forum.inductiveautomation.com/t/synchronize-multiple-tables-scroll-position/98052/2 "2024-11-01T19:35:04Z")

</div>

This will get you started. You should add a `ChangeListener` to sync the scrollbar positions.

In the `initialize` extension function on the first table add this script

```python
	from javax.swing.event import ChangeListener

	tableMain = self.parent.getComponent('Power Table')
	table2 = self.parent.getComponent('Power Table 1')
	
	class myListener(ChangeListener):
		def stateChanged(self, e):
			scrollBarMain = tableMain.getVerticalScrollBar()
			scrollBar2 = table2.getVerticalScrollBar()
			scrollBar2.setValue(scrollBarMain.getValue())
			
	#to remove ChangeListener
	listeners = tableMain.viewport.getChangeListeners()
	for listener in listeners:
		tableMain.viewport.removeChangeListener(listener)
		
	#to add ChangeListener
	tableMain.viewport.addChangeListener(myListener())

```

You may want to consider this comment from a similar thread.

> [@Scroll two (or more ) tables with one scroolbar](https://forum.inductiveautomation.com/t/scroll-two-or-more-tables-with-one-scroolbar/20125/3):
>
> I would add a ChangeListener to each table’s Viewport that would relay any desired operations to the other tables. And use mouseenter, mouseexit, and mousemove events to ensure only one table’s event are relayed at any given moment. The ChangeListener will get an event even if the scroll happens as a result of a non-mouse operation.

---

_[View the full topic](https://forum.inductiveautomation.com/t/synchronize-multiple-tables-scroll-position/98052)._
