Hello,
I have created a grid, but I am not able to bind a TextField (which is for Strings) to the column. Only a Slider is working. Is there an easier way to add a “TextField” for double values to a grid column for editing?
val grid = Grid<TypeConfig>(TypeConfig::class.java).apply {
[...]
addColumn(TypeConfig::triggerDiff, NumberRenderer())
.setEditorBinding(editor.binder.bind(
Slider(),
TypeConfig::triggerDiff.getter,
TypeConfig::triggerDiff.setter
))
.caption = "Trigger"
[...]
editor.isEnabled = true
setSizeFull()
}
I also tried to create my own “TextField” which could be used for Double Values. This is working, but I can not validate if the input is an double only:
[code]
import com.vaadin.ui.Component
import com.vaadin.ui.CustomField
import com.vaadin.ui.TextField
class DoubleField : CustomField() {
private var value: Double = 0.0
private var textField = TextField()
override fun initContent(): Component {
textField.value = value.toString()
textField.addValueChangeListener { event ->
this.value = event.value.toDouble() //Also typing non numbers is allowed
}
return textField
}
override fun getValue(): Double {
return value
}
override fun doSetValue(value: Double) {
this.value = value
}
}
[/code]Maybe I am doing something completely wrong?
Thanks!