cljfx

https://github.com/cljfx/cljfx
2020-09-15T02:17:17.116800Z

@vlaaad Question re: JavaFX TableView .scrollTo (int) support I do not see that cljfx has built-in support for scrolling to a target row index in a ":fx/type :table-view" component. Is it possible to implement this somehow with the current framework or must we suggest this as a new feature ?

vlaaad 2020-09-15T07:35:51.116900Z

Hi! It is possible to implement with current functionality available in cljfx, depends on how much reactivity you need there. If your table always exists in a display graph and you want to scroll it only from event handlers (e.g. by pressing the button), you can assign it an id, e.g. :id "the-table" , and lookup it by id from the event handler (e.g. (-> e .getTarget .getScene (.lookup "#the-table") (.scrollTo ...)) — this code might need some type hints, I haven’t tried it). Very easy, but fragile. If you want it more data-driven, you should use fx/make-ext-with-props to create a :scroll-to-row prop that will make the table scroll, and put the row you want to scroll to in the app state atom. Note that cljfx will mutate the display graph only when the app state changes, so setting the target row to the same value twice will have no effect on the second attempt. so it is a good idea to somehow reset the value in the app state to nil when the table is scrolled manually. This is harder, but reliable.

2020-09-15T13:35:42.117100Z

thanks @vlaaad for the quick reply ! will add the above and note the results here

2020-09-15T14:12:04.117300Z

@vlaaad - added the ':id' to the fx/type table-view and the .scrollTo logic into my event handler and it works perfectly thanks again !!

👍 1