json-editor
json-editor copied to clipboard
Set enumSource conditionally
Hi, Here is my schema:
{
"type" : "object",
"properties" :
{
"Makes" :
{
"type" : "array",
"enum" : [["Toyota","Honda","Ford"]],
"options" : { "hidden" : true}
},
"Models" :
{
"type" : "array",
"enum" : [["Camry", "Civic", "Focus"]],
"options" : { "hidden" : true}
},
"Filter" :
{
"type" : "array",
"items" :
{
"type" : "object",
"id" : "options",
"properties" :
{
"Key" :
{
"type" : "string",
"enum" : ["Make","Model"]
},
"Value" :
{
"type" : "string",
"enumSource" : ["makes", "models"],
"enumValue" : "{{item}}",
"watch" :
{
"makes" : "root.Makes",
"models" : "root.Models"
}
}
}
}
}
}
}
My goal is that when Key is being selected, Value enumSource to be set to Makes and when Model is selected, enumSource of the value field to be set to Models.
Is it possible? Thanks.
I think you are looking for oneOf? https://github.com/jdorn/json-editor/blob/master/examples/advanced.html
Thanks Lorenzbi, oneOf would work but I was hoping to have a better UI generated, something like cascade drop downs. I am not sure if that's possible though.
@rmeshksar Did you ever figure it out?