discobot
(discobot)
February 3, 2021, 1:54pm
1
Hi,
My question is, is there a way to render an array of objects (or strings), and be able to do select on them? I saw that enums are ok for selecting, but you must predefine values, and i saw arrays, Array Example - JSON Forms , but I don’t know is it possible to select an item from an array.
Thanks!
[original thread by Stefan Čović]
sdirix
(Stefan Dirix)
February 3, 2021, 3:02pm
2
Hi @stefan-covic ! You can specify arbitrary values when you use a oneOf
enum-like construction. They are specified like this:
"oneOf": [
{
"title": "Option1",
"const": // whatever value you like to have
},
{
"title": "Option2",
"const": // whatever value you like to have
}
]
Example:
{
"type": "object",
"properties": {
"name": {
"oneOf": [
{
"const": {
"foo": "bar",
"bar": "foo"
},
"title": "Option1"
},
{
"const": {
"foo2": "bar2",
"bar2": "foo2"
},
"title": "Option2"
}
]
}
}
}
sdirix
(Stefan Dirix)
February 3, 2021, 3:04pm
3
If you like to being able to define editable and selectable objects within one control then you will need to write a custom renderer.
discobot
(discobot)
February 3, 2021, 8:52pm
4
[Stefan Čović]
Thank you for the answer! But is it possible to set ‘oneOf’ array dynamically, outside of a schema, through the data?
discobot
(discobot)
February 4, 2021, 8:27am
6
[Stefan Čović]
Ok, thank you very much, appreciate it!