diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-01-16 15:12:55 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-01-16 15:12:55 +0100 |
commit | 2c4fe2ef6fd0a0bfa53f6496a1d4bede8fe9219d (patch) | |
tree | 93cfb31ba0749828ebb6805438c80a985ba8995c /src/main/kotlin/pl/treksoft/kvision/Showcase.kt | |
parent | bcc5292dd95e5824da41a19bfbf64ebc25d79102 (diff) | |
download | kvision-2c4fe2ef6fd0a0bfa53f6496a1d4bede8fe9219d.tar.gz kvision-2c4fe2ef6fd0a0bfa53f6496a1d4bede8fe9219d.tar.bz2 kvision-2c4fe2ef6fd0a0bfa53f6496a1d4bede8fe9219d.zip |
Radio button group form control
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/Showcase.kt')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/Showcase.kt | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt index a27fae2d..dfdc5b6b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt +++ b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt @@ -13,6 +13,7 @@ import pl.treksoft.kvision.form.INPUTSIZE import pl.treksoft.kvision.form.bool import pl.treksoft.kvision.form.check.CheckBox import pl.treksoft.kvision.form.check.Radio +import pl.treksoft.kvision.form.check.RadioGroup import pl.treksoft.kvision.form.date import pl.treksoft.kvision.form.select.AjaxOptions import pl.treksoft.kvision.form.select.SELECTWIDTHTYPE @@ -63,7 +64,7 @@ class Showcase : ApplicationBase() { val ret = form.getData() console.log(ret) - class DataFormMap(val map: Map<String, Any?>) { + class DataFormMap(map: Map<String, Any?>) { val name: String by map val age: Date by map } @@ -165,6 +166,24 @@ class Showcase : ApplicationBase() { } root.add(mbuttons3) + val rg = RadioGroup(listOf("o1" to "Pierwsza opcja", "o2" to "Druga opcja"), label = "Radio buttony") + root.add(rg) + val rgbutton = Button("Sprawdź radio").setEventListener<Button> { + click = { + println(rg.value) + } + } + root.add(rgbutton) + val rg2button = Button("Ustaw radio").setEventListener<Button> { + click = { + rg.value = "o2" + } + dblclick = { + rg.value = null + } + } + root.add(rg2button) + val select5 = Select(listOf("a" to "Pierwsza", "b" to "Druga"), "a", label = "Lista wyboru") root.add(select5) @@ -418,9 +437,10 @@ class Showcase : ApplicationBase() { val radio: Boolean by map val select: String? by map val spinner: Double? by map + val radiogroup: String? by map } - val formPanel = FormPanel() { + val formPanel = FormPanel { Formularz(it) }.apply { add("text", Text(label = "Tekst"), required = true, validatorMessage = { "Wprowadź tylko cyfry" }) { @@ -441,9 +461,11 @@ class Showcase : ApplicationBase() { emptyOption = true }, required = true) add("spinner", Spinner(label = "Spinner"), required = true) + add("radiogroup", RadioGroup(listOf("o1" to "Pierwsza opcja", "o2" to "Druga opcja"), + inline = true, label = "Radio group"), required = true) validator = { - var result = it["text"] == it["textarea"] + val result = it["text"] == it["textarea"] if (!result) { it.getControl("text")?.validatorError = "Niezgodne dane" it.getControl("textarea")?.validatorError = "Niezgodne dane" @@ -469,9 +491,10 @@ class Showcase : ApplicationBase() { } val formButton = Button("Pokaż dane").setEventListener<Button> { click = { + formPanel.getControl("radiogroup")?.disabled = true console.log(formPanel.validate()) console.log(formPanel.getData().map.toString()) -// formPanel.setData(Formularz(mapOf("zazn" to false, "select" to "a"))) + formPanel.setData(Formularz(mapOf("checkbox" to false, "select" to "a", "radiogroup" to "o2"))) spinner.toggleVisible() spinner.max = spinner.max.plus(2) ttt.toggleVisible() |