Class TableRowExpanderColumn<S>

  • Type Parameters:
    S - The item type of the TableView
    All Implemented Interfaces:
    Styleable, EventTarget

    public final class TableRowExpanderColumn<S>
    extends TableColumn<S,​Boolean>
    The TableRowExpanderColumn enables a TableView to provide an expandable editor below each table row. The column itself contains a toggle button that on click will show an editor for the current row right below the columns. Example:
     TableRowExpanderColumn<Customer> expander = new TableRowExpanderColumn<>(param -> {
         HBox editor = new HBox(10);
         TextField text = new TextField(param.getValue().getName());
         Button save = new Button("Save customer");
         save.setOnAction(event -> {
         editor.getChildren().addAll(text, save);
         return editor;
    You can provide a custom cellFactory to customize the toggle button. A typical custom toggle cell implementation would look like this:
     public class MyCustomToggleCell<S> extends TableCell<S, Boolean> {
         private Button button = new Button();
         public MyCustomToggleCell(TableRowExpanderColumn<S> column) {
             button.setOnAction(event -> column.toggleExpanded(getIndex()));
         protected void updateItem(Boolean expanded, boolean empty) {
             super.updateItem(expanded, empty);
             if (expanded == null || empty) {
             } else {
                 button.setText(expanded ? "Collapse" : "Expand");
    The custom toggle cell utilizes the toggleExpanded(int) method to toggle the row expander instead of param.toggleExpanded() like the editor does.
    • Constructor Detail

      • TableRowExpanderColumn

        public TableRowExpanderColumn​(Callback<TableRowExpanderColumn.TableRowDataFeatures<S>,​Node> expandedNodeCallback)
        Create a row expander column that can be added to the TableView list of columns. The expandedNodeCallback is expected to return a Node representing the editor that should appear below the table row when the toggle button within the expander column is clicked. Once this column is assigned to a TableView, it will automatically install a custom row factory for the TableView so that it can configure a TableRow with the ExpandableTableRowSkin. It is within the skin that the actual rendering of the expanded node occurs.
        expandedNodeCallback -
        See Also:
        TableRowExpanderColumn, TableRowExpanderColumn.TableRowDataFeatures
    • Method Detail

      • getExpandedProperty

        public BooleanProperty getExpandedProperty​(S item)
        Returns a Boolean property that can be used to manipulate the expanded state for a row corresponding to the given item value.
        item - The item corresponding to a table row
        The boolean property
      • getOrCreateExpandedNode

        public Node getOrCreateExpandedNode​(TableRow<S> tableRow)
        Get or create and cache the expanded node for a given item.
        tableRow - The table row, used to find the item index
        The expanded node for the given item
      • getExpandedNode

        public Node getExpandedNode​(S item)
        Return the expanded node for the given item, if it exists.
        item - The item corresponding to a table row
        The expanded node, if it exists.
      • toggleExpanded

        public void toggleExpanded​(int index)
        Toggle the expanded state of the row at the given index.
        index - The index of the row you want to toggle expansion for.