0

I have a tableview showing data of a record of a database.

I also have fields not in the table (in an extra pane) showing the same fields (for reason of convenience, in the table for easy sorting, outside for convenient changing)

Such; when i change a field not in the table, i need the table view changed accordingly: change -> db update -> new data into the table - it does not work. The view is not 'refreshed' (like e.g. in microsoft products).

A hacky solution works: i re-create the table every time and set it again (everything: build the columns, the listeners, set the selected item, and set this 'new' table instead of the existing). (another suggested solution in SO, set visible(false)/(true) - it did not work).

I found another 'solution' if said so: I set the changed value into the table.field directly. However then; the changed data is not shown as changed. - Only when i as a human access the header (double-mouse-click onto the header to trigger a sorting; it will finally update the view)

I would prefer not to re-create the table entirely every time. That is why, i would like to use the 'solution'. - But, i do not want to have to double-click onto the header as a human.

Such; i tried the Fire-Event as proposed in another post of SO, as that:

Pane header = (Pane) MY_TABLE.lookup("TableHeaderRow");
// to simulate a double-click onto the 2nd table-column-header
Event.fireEvent(header.getChildren().get(1) ...

.. it does not work; but i am not sure which 'node' i had to 'robo-click' onto either ..

it is hacky; but if someone could pls point to the solution i would be grateful. .. :) pls not a solution of setting an observable list etc; i have done so, to no avail. I just would like to make this 'hack' run; not to re-create the table every time.

  • if there was something like the table for javafx (java 8), maybe a private API, that offered view-updates when triggered by code; pls tell :)

Thank you!

luator
  • 4,769
  • 3
  • 30
  • 51
rbc
  • 35
  • 7
  • You **don't** need to create a new instance of `TableView` every time. Just updating its data should work. – ItachiUchiha Apr 16 '15 at 08:33
  • Can you elaborate why you insist on using the hacky way instead of using `ObservableList` the way it was meant to? – eckig Apr 16 '15 at 09:05
  • So you have tried [this](http://stackoverflow.com/questions/11065140/javafx-2-1-tableview-refresh-items?answertab=votes#tab-top) and did not help? – Uluk Biy Apr 16 '15 at 12:19
  • Hello all, thank you very much for your time answering, especially @UlukBiy, thank you surely is useful; for me, unfortunately it did not work either. 'insist' maybe not the correct word :) as i haven't found another way. Issue is: i implemented 2 'extra' things: whenever one is 'leaving' a field, the content is stored (and the field updated); another: from outside the table, i do a search and 'set' the table .. why not using the ObservableList as it is intended: b/c it does not 'serve' these 2 cases. Thank you all for answering, i close the question. – rbc Apr 18 '15 at 09:13

0 Answers0