diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-11-25 15:55:07 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-11-25 15:55:07 +0100 |
commit | c1bc80c0b7f851f14f40f9b087b37af6c2be83f8 (patch) | |
tree | 4ab2696c32ddcb59964c027f7fed0c7703dbd391 /kvision-modules/kvision-tabulator/src/main/kotlin/pl | |
parent | 1a5c45c2a6e2e53712d70d731f85a6b990cc464b (diff) | |
download | kvision-c1bc80c0b7f851f14f40f9b087b37af6c2be83f8.tar.gz kvision-c1bc80c0b7f851f14f40f9b087b37af6c2be83f8.tar.bz2 kvision-c1bc80c0b7f851f14f40f9b087b37af6c2be83f8.zip |
Support column groups in the Tabulator componenet (#111)
Diffstat (limited to 'kvision-modules/kvision-tabulator/src/main/kotlin/pl')
-rw-r--r-- | kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Options.kt | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Options.kt b/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Options.kt index 27911e52..66337568 100644 --- a/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Options.kt +++ b/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Options.kt @@ -261,6 +261,7 @@ fun DownloadConfig.toJs(): Tabulator.DownloadConfig { data class ColumnDefinition<T : Any>( val title: String, val field: String? = null, + val columns: List<ColumnDefinition<T>>? = null, val visible: Boolean? = null, val align: Align? = null, val width: String? = null, @@ -429,6 +430,7 @@ fun <T : Any> ColumnDefinition<T>.toJs( return obj { this.title = i18nTranslator(title) if (field != null) this.field = field + if (columns != null) this.columns = columns.map { it.toJs(i18nTranslator) }.toTypedArray() if (visible != null) this.visible = visible if (align != null) this.align = align.align if (width != null) this.width = width @@ -708,7 +710,8 @@ data class TabulatorOptions<T : Any>( fun <T : Any> TabulatorOptions<T>.toJs( i18nTranslator: (String) -> (String) ): Tabulator.Options { - val tmpCellEditCancelled = this.columns?.find { it.editorComponentFunction != null }?.let { + val allColumns = this.columns?.let { c -> c + c.mapNotNull { it.columns }.flatten() } + val tmpCellEditCancelled = allColumns?.find { it.editorComponentFunction != null }?.let { { cell: Tabulator.CellComponent -> cellEditCancelled?.invoke(cell) cell.getTable().redraw(true) |