column
Declares one column of V values, taking the column's class from the type value returns.
The class is what the table renders and edits the column's cells as, so a Boolean column draws a checkbox and hands onCellEdit a Boolean, and an Int column hands it an Int:
column("Name") { it.name }
column("Done", isEditable = true, onCellEdit = { row, _, done -> setDone(row, done) }) { it.isDone }
column("Owner", cellContent = { row -> FlowPanel { Label(row.owner) } }) { it.owner }Where the class is not the extractor's own, declare the column with the overload that takes it.
Parameters
the column's header text
whether this column's cells can be edited in place; false (the default) makes the whole column read-only
decides per row whether that row's cell in this column can be edited in place, answering for every row of the column while it is declared; null (the default) leaves the answer to isEditable
whether a click on this column's header sorts the rows by it; true (the default) lets it, while the table sorts at all
orders this column's cell values, or null (the default) to order them the way a TableRowSorter orders a column of V; applies while the table sorts at all. Hold one instance across passes: a comparator is compared by identity, so one built anew each pass - a capturing lambda, or a compareBy - sorts the rows again each pass
the narrowest this column may be dragged or squeezed to, in pixels; 15 by default, the minimum a TableColumn sets for itself
the widest this column may be dragged or stretched to, in pixels; Int.MAX_VALUE - the default - leaves it unbounded
invoked when a cell in this column is edited and the edit is committed, receiving the row, the row index, and the newly entered value; pair it with an isEditable of true and update the backing state from here so the next composition reflects the edit. An edit still open on a cell a later composition no longer describes - its row gone, rewritten in place, or its column rebuilt - ends there and commits nothing. An edit follows its row across rows inserted or removed elsewhere; a composition that both adds and removes rows ends an edit on any row at or past the first row where the two lists differ, and one on any row at all where the table is sorted or filtered, since a JTable cancels an editor over a change it cannot map an index across
renders this column's cells through a composable body, against a TableCellScope and the row each cell belongs to; null (the default) renders a cell through the renderer the table picks by V
extracts the cell value to display for a given row
See also
Declares one column of columnClass values.
A column's class is what the table renders and edits its cells as: a Boolean column draws a checkbox and commits a Boolean, a Number column edits through a text field and commits a number of that class. The overload without a class takes it from the type the value extractor returns and is the ordinary way to declare a column; reach for this one where the class is not the extractor's own.
Parameters
the column's header text
the class of the values this column holds
whether this column's cells can be edited in place; false (the default) makes the whole column read-only
decides per row whether that row's cell in this column can be edited in place, answering for every row of the column while it is declared; null (the default) leaves the answer to isEditable
whether a click on this column's header sorts the rows by it; true (the default) lets it, while the table sorts at all
orders this column's cell values, or null (the default) to order them the way a TableRowSorter orders a column of columnClass; applies while the table sorts at all. Hold one instance across passes: a comparator is compared by identity, so one built anew each pass - a capturing lambda, or a compareBy - sorts the rows again each pass
the narrowest this column may be dragged or squeezed to, in pixels; 15 by default, the minimum a TableColumn sets for itself
the widest this column may be dragged or stretched to, in pixels; Int.MAX_VALUE - the default - leaves it unbounded
invoked when a cell in this column is edited and the edit is committed, receiving the row, the row index, and the newly entered value; pair it with an isEditable of true and update the backing state from here so the next composition reflects the edit. An edit still open on a cell a later composition no longer describes - its row gone, rewritten in place, or its column rebuilt - ends there and commits nothing. An edit follows its row across rows inserted or removed elsewhere; a composition that both adds and removes rows ends an edit on any row at or past the first row where the two lists differ, and one on any row at all where the table is sorted or filtered, since a JTable cancels an editor over a change it cannot map an index across
renders this column's cells through a composable body, against a TableCellScope and the row each cell belongs to; null (the default) renders a cell through the renderer the table picks by columnClass
extracts the cell value to display for a given row