DataTableEditors

Ready-made editors for DataTableHeader.editorContent and the matching cell renderers, for the columns that do not want a free-text field.

DataTableHeader<Employee>(
key = "department",
value = { it.department },
editable = true,
cellContent = DataTableEditors.dropdownCell { it.department },
editorContent = DataTableEditors.dropdown(listOf("Finance", "IT", "Sales")),
)

DataTableHeader<Employee>(
key = "active",
value = { it.active },
editable = true,
editOnClick = true,
cellContent = DataTableEditors.checkboxCell { it.active },
editorContent = DataTableEditors.checkbox(),
)

Both editors commit through the column's validateEdit and report through onCellEdit like the built-in text field, so the reported text is the chosen option, or "true" / "false".

Functions

Link copied to clipboard
fun <T> checkbox(): @Composable (T, CellEditController) -> Unit

A boolean editor that flips the cell as soon as it opens, so Enter, F2, or a double-click toggles the value in one step. Pair it with checkboxCell so the cell shows the state, and with DataTableHeader.editOnClick to toggle on a single click.

Link copied to clipboard
fun <T> checkboxCell(isChecked: (T) -> Boolean): @Composable (T) -> Unit

Cell content drawing a read-only checkbox for a boolean column.

Link copied to clipboard
fun <T> dropdown(options: List<String>, label: (String) -> String = { it }): @Composable (T, CellEditController) -> Unit

A dropdown editor offering a fixed set of options.

Link copied to clipboard
fun <T> dropdownCell(text: (T) -> String): @Composable (T) -> Unit

Cell content for a dropdown column: the value followed by a chevron, so the column reads as a picker before it is opened.