ColumnsContext

class ColumnsContext<T>

This context class manages the configuration and defines the DSL for the overall declaration of the data table's columns.

The following aspects can be configured:

  • the styling for all columns (overriding the theme's default)

  • the individual columns by ColumnContext

This is how the DSL looks like:

columns({ // as first parameter you can pass a style that gets applied to *all* columns
background { color { "purple" } }
color { "white" }
}) { // opens the context for declaring the individual columns
column {
// and so on, Details in [ColumnContext]
}
}

The styling gets some meta information injected, an IndexedValue of type `IndexedValue<StatefulItem<T>>`, so that is is possible to react to the row position (odd vs even for example) or to the content itself:

columns({ (index, state) ->
if(item % 2 == 1) { // odd row
background { color { "purple" } }
color { "white" }
} else { // even row
background { color { "pink" } }
color { "black" }
}
if(state.selected) { // emphasize text if row is selected
fontWeight { bold }
}
// access model type specific properties
if(state.item.XYZ) {
// some specific styling based upon values of the model (think of ranges for example)
}
}) { // opens the context for declaring the individual columns
column {
// and so on, Details in [ColumnContext]
}
}

Inside of the `columns` context, only arbitrary amount of `column`s can be defined, but no other aspect!

See also

Constructors

ColumnsContext
Link copied to clipboard
js
fun ColumnsContext()

Types

ColumnContext
Link copied to clipboard
js
class ColumnContext<T>
This context class manages the configuration and defines the DSL for exactly one column.

Functions

column
Link copied to clipboard
js
fun column(styling: BasicParams.(value: IndexedValue<StatefulItem<T>>) -> Unit = {}, expression: ColumnsContext.ColumnContext<T>.() -> Unit)
This context function opens the ColumnContext for configuring one column of the table.
fun column(styling: BasicParams.(value: IndexedValue<StatefulItem<T>>) -> Unit = {}, title: String, expression: ColumnsContext.ColumnContext<T>.() -> Unit)
This context function opens the ColumnContext for configuring one column of the table.

Properties

columns
Link copied to clipboard
js
val columns: MutableMap<String, Column<T>>
styling
Link copied to clipboard
js
val styling: ComponentProperty<BoxParams.(IndexedValue<StatefulItem<T>>) -> Unit>