aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-tabulator/src/main
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-09-24 13:28:17 +0200
committerRobert Jaros <rjaros@finn.pl>2019-09-24 13:28:17 +0200
commit631bbc42ae4f7d806dcb66ed133e73eede860163 (patch)
treeef90340fa542f9e8a2aeff7fff8f70b96b3f706d /kvision-modules/kvision-tabulator/src/main
parent0da5f7d7b62d8d4183dade2a185eb688d8099b93 (diff)
downloadkvision-631bbc42ae4f7d806dcb66ed133e73eede860163.tar.gz
kvision-631bbc42ae4f7d806dcb66ed133e73eede860163.tar.bz2
kvision-631bbc42ae4f7d806dcb66ed133e73eede860163.zip
Expose native tabulator object as public property. Add new methods for column manipulation. (#77)
Diffstat (limited to 'kvision-modules/kvision-tabulator/src/main')
-rw-r--r--kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt50
1 files changed, 49 insertions, 1 deletions
diff --git a/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt b/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt
index 054bd9ee..da1f48de 100644
--- a/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt
+++ b/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt
@@ -64,7 +64,10 @@ open class Tabulator<T : Any>(
*/
var types by refreshOnUpdate(types)
- protected var jsTabulator: JsTabulator? = null
+ /**
+ * Native Tabulator object.
+ */
+ var jsTabulator: JsTabulator? = null
private var pageSize: Number? = null
private var currentPage: Number? = null
@@ -547,6 +550,51 @@ open class Tabulator<T : Any>(
jsTabulator?.navigateDown()
}
+ /**
+ * Get column component by name.
+ * @param name column name
+ * @return column component
+ */
+ open fun getColumn(name: String): JsTabulator.ColumnComponent? {
+ return jsTabulator?.getColumn(name)
+ }
+
+ /**
+ * Delete column by name.
+ * @param name column name
+ */
+ open fun deleteColumn(name: String) {
+ jsTabulator?.deleteColumn(name)
+ }
+
+ /**
+ * Add new column to the tabulator.
+ * @param columnDefinition column definition
+ * @param insertRightOfTarget determines how to position the new column
+ * @param positionTarget the field to insert the new column next to
+ */
+ open fun addColumn(
+ columnDefinition: ColumnDefinition<T>,
+ insertRightOfTarget: Boolean? = null,
+ positionTarget: String? = null
+ ) {
+ jsTabulator?.addColumn(columnDefinition.toJs(this::translate), insertRightOfTarget, positionTarget)
+ }
+
+ /**
+ * Add new column to the tabulator.
+ * @param columnDefinition column definition native object
+ * @param insertRightOfTarget determines how to position the new column
+ * @param positionTarget the field to insert the new column next to
+ */
+ open fun addColumn(
+ columnDefinition: JsTabulator.ColumnDefinition,
+ insertRightOfTarget: Boolean? = null,
+ positionTarget: String? = null
+ ) {
+ jsTabulator?.addColumn(columnDefinition, insertRightOfTarget, positionTarget)
+ }
+
internal fun removeCustomEditors() {
EditorRoot.cancel?.invoke(null)
EditorRoot.disposeTimer?.let { window.clearTimeout(it) }