DataTableHeader

@Immutable
data class DataTableHeader<T>(val key: String, val title: String = "", val value: (T) -> Any?? = null, val sortable: Boolean = true, val width: Dp? = null, val align: TextAlign = TextAlign.Start, val fixed: Boolean = false, val visible: Boolean = true, val maxLines: Int = Int.MAX_VALUE, val overflow: TextOverflow = TextOverflow.Clip, val comparator: <Error class: unknown class><T>? = null, val children: List<DataTableHeader<T>>? = null, val headerContent: @Composable () -> Unit? = null, val cellContent: @Composable (T) -> Unit? = null, val editable: Boolean = false, val editValue: (T) -> String? = null, val validateEdit: (T, String) -> String?? = null, val editorContent: @Composable (T, CellEditController) -> Unit? = null, val format: (Any?) -> String? = null, val filterable: Boolean = false, val filterPlaceholder: String = "", val filterPredicate: (T, String) -> Boolean? = null, val filterContent: @Composable (ColumnFilterController) -> Unit? = null, val editOnClick: Boolean = false)(source)

Describes a column in the DataTable.

Parameters

key

Stable unique identifier for this column. Also used for sorting.

title

Text label shown in the default header when headerContent is not provided.

value

Extractor invoked for each row item to produce a displayable value.

sortable

Whether this column supports sorting via the built-in header interactions.

width

Fixed width for the column. If null, the column is laid out with weight to fill space.

align

Horizontal alignment for header text and default cell text.

fixed

When true, the column is frozen (pinned) to the left and does not scroll horizontally. Frozen columns must have an explicit width; DataTable throws if one does not.

visible

When false, the column is excluded from rendering. Defaults to true.

maxLines

Maximum lines for default text rendering. Defaults to Int.MAX_VALUE.

overflow

Text overflow strategy for default text rendering.

comparator

Optional custom comparator for sorting. When provided, takes precedence over the default Comparable-based sort.

children

Optional nested headers. When provided, this header becomes a group: it is drawn as a band above its children, spanning them, and only the leaf headers render as actual columns. A group's own value, width, and sorting settings are ignored — it takes its width from the leaves beneath it, which must be either all fixed-width or all weighted.

headerContent

Optional composable to fully customize the header cell for this column.

cellContent

Optional composable to fully customize each body cell for this column.

editable

Whether cells in this column can be edited in place. Declaring any editable column turns on DataTable's cell-level focus and grid keyboard navigation, and requires an onCellEdit callback for the edit to go anywhere — the table reports edits, it never mutates your items.

editValue

Text the editor opens with. Defaults to value's result rendered with toString() — the raw value, never the formatted one, since formatted text is rarely text you can type back. Set this where even the raw form is not what you want typed: 92000.0 for a salary held as a Double, or an enum's name.

validateEdit

Checks a value the user is trying to commit, returning an error message to reject it or null to accept. A rejected commit keeps the editor open with the message on DataTableState.editError. This is the guard that stops unparseable text ever reaching onCellEdit.

editorContent

Optional composable replacing the built-in text field — a dropdown, a date picker, a lookup. It is handed the row and a CellEditController to commit or cancel with, and is expected to take keyboard focus itself.

format

Turns the value value extracted into the text the cell shows. Formatting here rather than inside value is what keeps a column's raw value raw: { it.salary } reads $92,000 and still sorts numerically, with no comparator to make up for a value that had become a string. Clipboard copy takes the formatted text — what you see is what you copy — while an editor still opens on the raw value, or on editValue. Ignored when cellContent draws the cell itself, though copy still uses it. DataTableFormatters has ready-made ones for money, numbers, percentages, dates, and booleans.

filterable

Whether this column gets a field in the filter row. Declaring any filterable column is what makes DataTable draw that row at all.

filterPlaceholder

Hint text shown in an empty filter field. Worth setting where the column title alone does not say what to type.

filterPredicate

Decides whether one item matches a query. The default is a case-insensitive "contains" against both the text the cell shows and the raw value, so a salary reading $92,000 is found by 92,0 and by 92000 alike. Supply one for anything else — a number range, a date window, a set of accepted codes.

filterContent

Optional composable replacing the built-in text field — a dropdown of the values that occur, a range picker, a tri-state flag. It is handed a ColumnFilterController to read the current query from and to set the new one with, and supplying it opts the column into the filter row on its own.

editOnClick

Whether a single click on an editable cell opens its editor, instead of moving the cell cursor and waiting for Enter, F2, or a double-click. With DataTableEditors.checkbox it makes one click toggle the value. Shift-clicks still extend the selection without editing.

Constructors

Link copied to clipboard
constructor(key: String, title: String = "", value: (T) -> Any?? = null, sortable: Boolean = true, width: Dp? = null, align: TextAlign = TextAlign.Start, fixed: Boolean = false, visible: Boolean = true, maxLines: Int = Int.MAX_VALUE, overflow: TextOverflow = TextOverflow.Clip, comparator: <Error class: unknown class><T>? = null, children: List<DataTableHeader<T>>? = null, headerContent: @Composable () -> Unit? = null, cellContent: @Composable (T) -> Unit? = null, editable: Boolean = false, editValue: (T) -> String? = null, validateEdit: (T, String) -> String?? = null, editorContent: @Composable (T, CellEditController) -> Unit? = null, format: (Any?) -> String? = null, filterable: Boolean = false, filterPlaceholder: String = "", filterPredicate: (T, String) -> Boolean? = null, filterContent: @Composable (ColumnFilterController) -> Unit? = null, editOnClick: Boolean = false)

Properties

Link copied to clipboard
val align: TextAlign
Link copied to clipboard
val cellContent: @Composable (T) -> Unit? = null
Link copied to clipboard
Link copied to clipboard
val comparator: <Error class: unknown class><T>? = null
Link copied to clipboard
val editable: Boolean = false
Link copied to clipboard
val editOnClick: Boolean = false
Link copied to clipboard
val editorContent: @Composable (T, CellEditController) -> Unit? = null
Link copied to clipboard
val editValue: (T) -> String? = null
Link copied to clipboard
val filterable: Boolean = false
Link copied to clipboard
val filterContent: @Composable (ColumnFilterController) -> Unit? = null
Link copied to clipboard
Link copied to clipboard
val filterPredicate: (T, String) -> Boolean? = null
Link copied to clipboard
val fixed: Boolean = false
Link copied to clipboard
val format: (Any?) -> String? = null
Link copied to clipboard
val headerContent: @Composable () -> Unit? = null
Link copied to clipboard
val key: String
Link copied to clipboard
Link copied to clipboard
val overflow: TextOverflow
Link copied to clipboard
val sortable: Boolean = true
Link copied to clipboard
Link copied to clipboard
val validateEdit: (T, String) -> String?? = null
Link copied to clipboard
val value: (T) -> Any?? = null
Link copied to clipboard
val visible: Boolean = true
Link copied to clipboard
val width: Dp? = null