https://kotlinlang.org logo
j

Jörg Rade

01/31/2022, 4:38 PM
I try to set a filter on a Tabulator table:
Copy code
fun filterByState(state: EventState) {
    console.log("[ELT.filterByState]")
    console.log(tabulator)
    tabulator.jsTabulator?.setFilter("State", "=", state.name)
}
tabulator looks as expected and it's element jsTabulator seems to be set, but when I try to access or log it, it is null. I'm puzzled (and still at KVision 5.5.1).
r

Robert Jaros

01/31/2022, 4:41 PM
I would suppose that you are calling
filterByState
too early, before `jsTabulator`is initialized.
Tried to log
tabulator.jsTabulator
?
j

Jörg Rade

01/31/2022, 4:42 PM
Yes I did and it's null
What can I do to force initialization?
Use a callback?
r

Robert Jaros

01/31/2022, 4:43 PM
when you log
tabulator
it will be "live" object - when you look at its properites in devtools you see the current state (not the state from the moment of logging)
j

Jörg Rade

01/31/2022, 4:44 PM
makes sense
r

Robert Jaros

01/31/2022, 4:44 PM
you should use after insert hook
👍 1
note, tabulator 5 (kvision 5.6.0+) is asynchronous by design
😁 1
you will probably have to add second callback 🙂
j

Jörg Rade

01/31/2022, 4:47 PM
Thanks for the info and your help!
r

Robert Jaros

01/31/2022, 4:47 PM
but I'm not sure - just remember this when you upgrade 🙂
j

Jörg Rade

02/01/2022, 5:28 PM
In
TabulatorOptions
there is
initialFilter: List<Tabulator.Filter>?
How can I create a
List<Tabulator.Filter>
?
r

Robert Jaros

02/01/2022, 5:41 PM
Copy code
initialFilter = listOf(obj<Tabulator.Filter>{
    field = "field1"
    type = "="
    value = "something"
})
j

Jörg Rade

02/01/2022, 8:06 PM
👍
4 Views