Search code examples
tornadofx

Tornadofx Tableview row count


Hey guys can someone please enlighten me. what is the best way to have a label display SortedFilteredList size. I have a tableview and I want a label showing the current table row count while filtering using filterwhen


Solution

  • All you need to do is to create a StringBinding towards the sizeProperty of the SortedFilteredList. I've added an example to the TableViewSortFilterTest in the framework, check out https://github.com/edvin/tornadofx/blob/master/src/test/kotlin/tornadofx/testapps/TableViewSortFilterTest.kt for a complete example. Here I add an informational hbox to the bottom of the screen:

    hbox(5) {
        label("Filter count:")
        label(data.sizeProperty.stringBinding { "$it records matching filter" })
    }
    

    The data property is my SortedFilteredList instance.