-
Notifications
You must be signed in to change notification settings - Fork 271
Streamlining CellFactories #67
Comments
Here are the Cell Factories for
I'm sure there are other cell factories for other data controls. |
By the way, how exactly do I properly bind the column("CONFLICTED", ParsedTransaction::conflictProperty).apply {
cellFactory = CheckBoxTableCell.forTableColumn(this)
setOnEditCommit {
it.tableView.items[it.tablePosition.row].conflict = it.newValue
}
} |
That's a good idea. It should be possible to add a function that will be called on commit as well, for example to automatically save changes etc. |
Yes, and literally just seconds before you I just posted an issue I was having with |
I think the default behavior is to cancel the commit when you just leave focus from the cell, which is counter to what users expect. Is this what you're experiencing? |
Maybe, although the values are being pushed from the model and not the user inputs. Let me see if I can post an SSCCE later, which we can also use for testing when we make these factories. |
Great! My experience is that you only need to do what you listed above, unless you want to override the default behavior of cancelling the edit on focus lost. |
I've started working on an implementation here in the meantime :) |
Initial suggestion for fun <S, T> TableColumn<S, T>.makeComboBox(items: ObservableList<T>, afterCommit: (TableColumn.CellEditEvent<S, T>.() -> Unit)? = null): TableColumn<S, T> {
cellFactory = ComboBoxTableCell.forTableColumn(items)
setOnEditCommit {
val property = it.tableColumn.getCellObservableValue(it.rowValue) as ObjectProperty<T>
property.value = it.newValue
afterCommit?.invoke(it)
}
return this
} |
Excellent! Just played with it and this is exactly what I was looking for. |
Commited |
…`makeChoiceBox`, `makeProgressBar` and `makeCheckbox` (#67)
Awesome, I'll test it with my application today. |
Great! Let me know how it works, or if you can identify the problem you saw as well! |
I think I got the names wrong. |
Maybe |
|
Hahaha, I'm biased towards |
|
Just crated a DatePickerTableCell @thomasnield: https://github.com/edvin/tornadofx-controls/releases/tag/v1.0.4 I will add TornadoFX Controls as an optional dependency and support |
About naming.. We already have |
I need to look again at your controls project as I think I need it for some things. And thanks for the DatePicker! So you're saying makeXXX is not an ideal naming convention? |
I think there's some interesting behaviors with |
Sometimes it's nice to be able to show checkboxes that are not editable for boolean properties, I'll see if I can get it working! I little short on time today, but I'll fix it tomorrow :) Nice catch! |
Oh, and yeah, there is something with the naming that seems off to me. I'll discuss with a couple of colleagues tomorrow to try to get some ideas and report back. Hoping to land these features and maybe do a release before the weekend. Have a few other functions I'd like to get in as well :) |
Awesome, I'll let you know if I have any ideas. Sorry I've been busy this past two days, I'll see if I can allocate some time to ponder this too. |
Just renamed the functions like we talked about :) I will close this now, the CheckBoxTableCell is really a JavaFX issue, so I won't use any more time on it now. |
Agreed. Awesome. |
I wonder if there is opportunity to improve the cell factories for
TableView
and other data controls.For instance, setting a mutable column in
TableView
to use aComboBoxTableCell
feels like it could be streamlined.It really should be just as easy as giving a
List<R>
or anObservableList<R>
for a givenTableColumn<T,R>
and theComboBox
just plugs in automagically.The text was updated successfully, but these errors were encountered: