I'm still getting used to the way the IR compiler ...
# kvision
h
I'm still getting used to the way the IR compiler mangles field names. Should the tabulator module work with Kotlin models? I feel like my column definitions are going to be referencing field names that don't exist on the generated object.
r
You need to add
@JsExport
to your model data class.
h
Thanks. I know I've seen that mentioned but it's never seemed to work for me
r
And tabulator module should handle the conversion between kotlin class and js object.
h
going to try it now ๐Ÿ™‚
legend ๐Ÿ™‚
Still loving KVision on a daily basis. Thanks @Robert Jaros
๐Ÿ‘ 1
Found something I hadn't experienced before:
Copy code
@JsExport
class Child(val name: String)

@JsExport
class Parent(val name: String, val child: Child)

fun Container.parentTable(parents: List<Parent>) {
    tabulator(
        parents, options = TabulatorOptions(
            columns = listOf(
                ColumnDefinition("Parent Name", "name"),
                ColumnDefinition("Child Name", "child.name"),
            )
        )
    )
}
fails with:
Uncaught TypeError: Cannot set property name of #<Child_0> which has only a getter
at e.n._setNestedData (tabulator.min.js?7558:2)
at u.setValueActual (tabulator.min.js?7558:5)
at u.build (tabulator.min.js?7558:4)
at new u (tabulator.min.js?7558:4)
at e.n.generateCell (tabulator.min.js?7558:3)
at eval (tabulator.min.js?7558:2)
at Array.forEach (<anonymous>)
at t.generateCells (tabulator.min.js?7558:2)
at l.generateCells (tabulator.min.js?7558:4)
at l.initialize (tabulator.min.js?7558:4)
If I set the "name" fields to vars instead of vals then it's happy
This seems to work in my older project using legacy backend, so I think they're now actively removing setters from immutable fields
which must mess up whatever values (cloned or raw) tabulator uses
thought that was interesting. Obviously I can just have my UI model fields be mutable and convert between immutable data model and mutable view model as necessary
r
Yes. I forgot to mention this. You need to have "vars" in your model.
h
No problem. Thanks ๐Ÿ˜Š
r
Tabulator integration with IR backend is a pain! ๐Ÿ™‚
h
Yeah I'm looking forward to the benefits IR brings ๐Ÿ˜‚
So far it's mostly making things harder