I have two tables which i would like to scroll synchronously.
I am using pturmel’s example (Freeze table column), and everything is working fine.
But I would like add some point to stop that ChangeListener and break synchronous scrolling two tables. Not sure how to do this. There is removeChangeListener() but i did not figure out how to use it.
Also, where can be found some details regarding viewport, especially for Table Component (table.viewport)?
You have to pass the listener you want to remove to the removeChangeListener() method. Which means you need to save it somewhere persistent. A client property of the component is probably the best place.
I tried client property. I added myScrollEvent to Button_1, and save it as myClientProperty_1, and then use another Button_2, get myClentProperty_1, print myScrollProperty_1 (<function myScrollEvent at 0x2>), but when i try to remove change listener “tblT22.viewport.removeChangeListener(myScrollEvent)”, nothing happens. Change listener is still active and both table are still scroll synchronously.
What i am doing wrong?
Ah, I think you’ll actually have to subclass the ChangeListener interface. I think that happens under the hood if you just add a callable, so the callable isn’t really the ChangeListener. If you subclass it, jython shouldn’t transform it automagically.
If you're attempting this from Perspective, it won't work. In Vision, if you are using a Power Table, this will work in the initialize extension function, and if you are just using a regular Table, this will work from the componentRunningpropertyChange event. [The componentRunning event will also work on the Power Table]
Notes:
• If you use theinitialize extension function, all instances of event.source will need to be replaced with self.
• If you are using the propertyChange event handler, you can use the code as is, but it needs to be nested in an if statement, or you'll end up with a million listeners on your tables:
if event propertyName == 'componentRunning':
# nest the code here
• The componentRunning event doesn't occur in the designer unless preview mode is started before the window with the script is opened, and the only time I've seen the initialize extension function run in the designer has been when my Power Tables are loaded by a temple repeater or canvas , so testing in a session could be necessary for your user case.