From e92f7e64f3aa468f178a68b43471b755de33eecd Mon Sep 17 00:00:00 2001 From: Teo Fonrouge Date: Thu, 2 Jan 2025 19:00:39 -0600 Subject: [PATCH] Add custom events for "pageLoaded" and "tableBuilt" Dispatch custom events "pageLoadedTabulator" and "tableBuiltTabulator" to enhance integration flexibility. These events provide additional hooks for external systems to react to Tabulator state changes. --- .../src/jsMain/kotlin/io/kvision/tabulator/Tabulator.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kvision-modules/kvision-tabulator/src/jsMain/kotlin/io/kvision/tabulator/Tabulator.kt b/kvision-modules/kvision-tabulator/src/jsMain/kotlin/io/kvision/tabulator/Tabulator.kt index 9ce37cb66d..e3d134ccd5 100644 --- a/kvision-modules/kvision-tabulator/src/jsMain/kotlin/io/kvision/tabulator/Tabulator.kt +++ b/kvision-modules/kvision-tabulator/src/jsMain/kotlin/io/kvision/tabulator/Tabulator.kt @@ -291,7 +291,7 @@ open class Tabulator( }, 0) } } - jsTabulator?.on("pageLoaded") { + jsTabulator?.on("pageLoaded") { pageNo: Int -> paginations.forEach { it.paginationState.value = PaginationState( jsTabulator?.getPage()?.unsafeCast() ?: 1, @@ -299,6 +299,7 @@ open class Tabulator( jsTabulator?.options?.paginationButtonCount?.unsafeCast() ?: 5 ) } + this.dispatchEvent("pageLoadedTabulator", obj { detail = pageNo }) } jsTabulator?.on("tableBuilt") { if (currentPage != null) { @@ -307,6 +308,7 @@ open class Tabulator( } applyFilter() jsTabulatorInitialized = true + this.dispatchEvent("tableBuiltTabulator", obj { }) } } }