2

Heey there! I've recently started working with Java & javaFX so i'm still quite new!

To the point; I want to make a tableview which has a separator/header/grouping for rows.

This is an example of what i want to achieve:

Example image

Animation has the grouped results of all "Animation" things, it seems when hovering over it that it acts like the column headers at the top.

With this in mind, i did some research and came across things like, CellFactory/RowFactory or CSS styling. I've also seen and thought of possibilities to make sub-table views perhaps where the columns are hidden except for 1 sub column ("Animation" in this case) and bind the sizing to the columns at the top.

But i couldn't exactly find how to apply any of the approaches to my situation and would love some help and shared wisdom for my personal experience :D

Below is my FXML code right now where i got the basic layout made for the tableview with 4 columns.

      <TableView prefHeight="280.0" prefWidth="655.0" GridPane.rowIndex="1" GridPane.rowSpan="2">
        <columns>
          <TableColumn editable="false" prefWidth="120.0" text="Command" />
          <TableColumn editable="false" prefWidth="120.0" text="Type" />
          <TableColumn editable="false" prefWidth="120.0" text="Pack" />
          <TableColumn editable="false" prefWidth="120.0" text="Path" />
        </columns>
      </TableView>

I hope i provided enough information, there isn't much more regarding my specific question (i got a controller class but it currently only opens a Directory browser). If there is need for info i'd gladly share!

Thanks for your time!

NotZack
  • 518
  • 2
  • 9
  • 22
  • Have you looked at `TreeTableView`? – SedJ601 Aug 30 '19 at 16:29
  • https://stackoverflow.com/questions/36917220/javafx-treetableview-leaves-icons-behind-when-collapsing – SedJ601 Aug 30 '19 at 16:29
  • I have actually, but i'm not really looking for something that collapses or opens up. Unless it's possible (or easier/wiser) to style it in a different fashion to look similar to the example! i assume it's possible to disable the collapsing and such right? – Dragonfreaky Aug 30 '19 at 17:29
  • This may be possible with a `TreeTableView` or maybe even just a `TableView`, though I haven't looked into it as of yet. What should happen while scrolling down? Should the "row header" just scroll out of sight like any other row or should it "stick" to the top until another "row header" comes along and displaces it? – Slaw Aug 31 '19 at 10:03
  • not supported - I would try with a custom TableRow. Or have a look at spreadsheet in ControlsFx: rows can be nearly anything (never tried, though) – kleopatra Aug 31 '19 at 10:08
  • @Slaw Aye, the "row header" does scroll out of view. When clicking on it, it'll select all the rows in that category (Tho, i don't need this feature personally). However, the "sticking" at top does sound neat! However that's more an extra eye candy for the future if possible :P But as mentioned by kleopatra it does seem i would need custom TableRow which sounds interesting! I don't know if anyone has an example of a custom TableRow? Much appreciated for all comments so far! – Dragonfreaky Aug 31 '19 at 11:20

0 Answers0