https://kotlinlang.org logo
#kvision
Title
# kvision
t

Tom

03/07/2021, 7:39 PM
Having some trouble with Tabulator and kvision 4.1.1. Using Tabulator with a ObservableList (backend is ktor). With 4.1.1 the Tabulator rows are created but empty, header is visible. Going back to 4.0.0 solves this issue. (kotlin.js.compiler=ir)
Copy code
val tab_options = TabulatorOptions(
        layout = Layout.FITCOLUMNS,
        columns = listOf(
                ....
        )
)
tabulator(Model.cov_List, options = tab_options)
r

Robert Jaros

03/07/2021, 9:00 PM
There should be no difference between 4.1.1 and 4.0.0 with IR
Could you give more details?
t

Tom

03/07/2021, 9:39 PM
It's a very basic fullstack project based on fullstack-ktor. Client side
Copy code
suspend fun aktuelleFälle(bezirk: String) {
    val newCases = caseService.aktuelleFälle()
    cov_List.syncWithList(newCases)
}
Transfer between server and client side and syncing works. The data is in the ObservableList. The Tabulator rows get even created, but are empty (no text). Changing back to 4.0.0 in gradle.properties fixes the problem.
r

Robert Jaros

03/07/2021, 9:42 PM
What type of data is in the list?
t

Tom

03/07/2021, 9:45 PM
Copy code
@Serializable
data class Cov_GKZ(
    val Bezirk: String,
    val GKZ: Int,
    val AnzEin: Int,
    val Anzahl: Int,
    val AnzTot: Int,
    val Anz7Tage: Int,
    val Inz7Tage: Int
)
r

Robert Jaros

03/07/2021, 9:46 PM
I think I know ...
On IR you need to annotate your data class with
@JsExport
It could work with 4.0.0, because 4.0.0 has a bug 🙂
Let me know if adding
@JsExport
fixes the problem.
t

Tom

03/07/2021, 9:54 PM
Oh, thanks a lot.
Copy code
@Serializable
@OptIn(ExperimentalJsExport::class)
@JsExport
data class Cov_GKZ(
    val Bezirk: String,
    val GKZ: Int,
    val AnzEin: Int,
    val Anzahl: Int,
    val AnzTot: Int,
    val Anz7Tage: Int,
    val Inz7Tage: Int
)
Doesn't solve the issue for me.
r

Robert Jaros

03/07/2021, 10:15 PM
It works for me. How do you define your columns?
I run this code:
Copy code
@Serializable
@OptIn(ExperimentalJsExport::class)
@JsExport
data class Cov_GKZ(
    val Bezirk: String,
    val GKZ: Int,
    val AnzEin: Int,
    val Anzahl: Int,
    val AnzTot: Int,
    val Anz7Tage: Int,
    val Inz7Tage: Int
)

val list = observableListOf(Cov_GKZ("a", 1, 2, 3, 4, 5, 6), Cov_GKZ("b", 2, 3, 4, 5, 6, 7))
// ...
        root("kvapp") {
            val tab_options = TabulatorOptions(
                layout = Layout.FITCOLUMNS,
                columns = listOf(ColumnDefinition("A", Cov_GKZ::Bezirk.name), ColumnDefinition("B", Cov_GKZ::GKZ.name))
            )
            tabulator(list, options = tab_options)
        }
And I see the data in both columns I defined.
Are you absolutely sure you get the right data from your backend? Have you tried just adding some records manually to your list?
4.1.1 upgraded Ktor to 1.5.2 - perhaps there is some problem in this?
t

Tom

03/07/2021, 10:34 PM
Thanks a lot 👏, problem is fixed. The problem was a mismatch between the data and the ColumnDefinition. Interestingly 4.0.0 was fault tolerant in this case.
3 Views