How to populate select from json
How to populate select from json
I have an editor that is calling a REST service. I have complete control over how the GET/{id} responds. In the Editor, I want to use a select box pre-populated with a list of values with the current value of the object already selected.
For this example, a Select box would be rendered in the editor with Houston selected with other options being Dallas, Austin, and San Antonio.
Here is the JSON.
{
"distribution": "Houston",
"distributionOptions": [
"Houston",
"Dallas",
"Austin",
"San Antonio"
],
...
}
Here is the Field:
fields: [ {
label: "Distribution:",
name: "distribution",
type: "select",
options: "distributionOptions"
},
...
]
Any ideas?
Best Wishes,
ks
This question has an accepted answers - jump to answer
Answers
Hi,
if you are using the
ajax
option to load the data into DataTables, you can also include anoptions
parameter in the JSON which would include the options for the various fields that need them. There is some documentation on this topic here.You can also see it in action here.
Thanks,
Allan