0

Is it possible in javaFX to obtain a grouping of the rows in a table view as in the following example? I've seen possible TreeTableView implementations but that's not quite what I want to achieve. Thanks Example

  • 3
    Unfortunately, grouping is not supported in JavaFX's `TableView`, but you can use [TreeTableView](https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/TreeTableView.html) to make something similar to what you want. – Miss Chanandler Bong Sep 13 '21 at 09:26
  • 1
    another option might be GridView in controlsFX – kleopatra Sep 13 '21 at 09:28
  • Perhaps you could achieve this through a [custom row factory](https://openjfx.io/javadoc/16/javafx.controls/javafx/scene/control/TableView.html#setRowFactory(javafx.util.Callback)), if so, it would likely be very difficult to do well. – jewelsea Sep 13 '21 at 19:19
  • @jewelsea Just curious: Do you mean the group would be a single row, and the row factory would render that to look like multiple rows, or would you have two kinds of items in the table list, and the row factory would simply render the "headers" different from the "real items" (in this case you'd only have to make sure the items are in the list in the correct order). Or something else? – Slaw Sep 14 '21 at 00:21
  • @Slaw a row is a cell and row factory is similar. You create a row that changes appearance depending on type of data for the row item. Use polymorphism for the items if they are headers render row one way and if detail render differently (just a standard row). It is kind of a variation of [this answer](https://stackoverflow.com/questions/17067481/javafx-2-tableview-different-cell-factory-depending-on-the-data-inside-the-cel) but for rows instead of individual cells. I haven’t tried it, so may not work, but that is the theory. – jewelsea Sep 14 '21 at 02:41
  • the row factory would simply render the "headers" different from the "real items“ <- yes that is right. For the ordering you could provide a special sorting comparator that grouped items under headers perhaps (not sure if that would be needed). – jewelsea Sep 14 '21 at 02:44

0 Answers0