I try to set a filter on a Tabulator table: ```fun...
# kvision
j
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
I would suppose that you are calling
filterByState
too early, before `jsTabulator`is initialized.
Tried to log
tabulator.jsTabulator
?
j
Yes I did and it's null
What can I do to force initialization?
Use a callback?
r
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
makes sense
r
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
Thanks for the info and your help!
r
but I'm not sure - just remember this when you upgrade 🙂
j
In
TabulatorOptions
there is
initialFilter: List<Tabulator.Filter>?
How can I create a
List<Tabulator.Filter>
?
r
Copy code
initialFilter = listOf(obj<Tabulator.Filter>{
    field = "field1"
    type = "="
    value = "something"
})
j
👍