rjaros / kvision

Object oriented web framework for Kotlin/JS
https://kvision.io
MIT License
1.2k stars 67 forks source link

How to do table with data tree? #468

Closed chavu closed 1 year ago

chavu commented 1 year ago

I have need for a table displaying hierarchical data, something like what is shown here https://tabulator.info/examples/5.4#tree. In my data I'm using a parent field/column to link the items into a hierarchy as shown by model data class below. Top level items have no parent, but all lower level items have a parent How can I achieve this data tree table in KVision using tabulator component or any other method?

@Serializable
data class MyModel(
    var id: Int,
    var parentId: Int?,
    var level: Int,
    val title: String,
    val description: String?,
    val leadPerson: String,
)           
rjaros commented 1 year ago

It will not work with this model. You need to transform your data to a tree structure compatible with tabulator (using a _children property - see https://tabulator.info/docs/5.4/tree#structure).

chavu commented 1 year ago

Thank you. I managed by transformign the data as you pointed out.