Skip to content

Instantly share code, notes, and snippets.

@elexx
Created March 8, 2018 08:08
Show Gist options
  • Save elexx/f87b0ee4b787b9b17fe72400894b94ff to your computer and use it in GitHub Desktop.
Save elexx/f87b0ee4b787b9b17fe72400894b94ff to your computer and use it in GitHub Desktop.
disappearing rows
import javafx.collections.FXCollections
import tornadofx.*
class TestView : View("My View") {
private val persons = FXCollections.observableArrayList<PersonModel>()
private val sortedFilteredPersons = SortedFilteredList(persons)
init {
persons.add(PersonModel(Person("Jane", "Doe")))
persons.add(PersonModel(Person("Max", "Doe")))
}
override val root = vbox {
textfield {
promptText = "Filter"
sortedFilteredPersons.filterWhen(textProperty(), { query, item ->
item.firstname.value.contains(query, ignoreCase = true) ||
item.lastname.value.contains(query, ignoreCase = true)
})
}
tableview<PersonModel> {
sortedFilteredPersons.bindTo(this)
column("Firstname", PersonModel::firstname)
column("Lastname", PersonModel::lastname)
}
}
}
data class Person(val firstname: String, val lastname: String)
class PersonModel(person: Person) : ViewModel() {
val firstname = observable(person, Person::firstname)
val lastname = observable(person, Person::lastname)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment