json-schema-form / angular-schema-form

Generate forms from a JSON schema, with AngularJS!
https://json-schema-form.github.io/angular-schema-form
MIT License
2.47k stars 653 forks source link

Cascading menu to select value #925

Closed Thorski closed 6 years ago

Thorski commented 7 years ago

Enhancement

Is it possible to make a cascading menu for selecting a value. Perhaps some array of arrays in titleMap?

Use case is user needs to pick a node in a large hierarchy of values.

Root ->
  Top Level 1 ->
     Next Level 1-1 ->
       Third Level 1-1-1
       Third Level 1-1-2
     Next Level 1-2 ->
  ... etc

@json-schema-form/angular-schema-form-lead

Anthropic commented 7 years ago

@Thorski you can use arrays in arrays as long as the key names are unique, you could use a select (one of the dynamic select add-ons) which loads related level data if you know how many levels deep the user may go as well.

Thorski commented 7 years ago

@Anthropic thank you for your answer, but I cannot figure out how to structure this. If you could provide a simple example I would greatly appreciate it. Thank you.

"titleMap": [
  {
    "value": "1",
    "name": "Ohio",
    "type": "select",
    "children": [
      { "value": "2", "name": "Delaware" }
    ]
  },
]
Anthropic commented 7 years ago

Can you give me an example of the data you want from the output and perhaps an example of the tree?

Did you take a look at external options, there is a state/city/suburb picker in the example: https://github.com/Anthropic/angular-schema-form-external-options

Thorski commented 6 years ago

I had not looked at or seen the external options. Thank you. I have since wrapped ngx-tree-select in a custom widget and am using that.

Anthropic commented 6 years ago

Closing since you found a solution :)

Please re-open if you do not feel the question has been answered sufficiently.

jasminecjc commented 6 years ago

what's your solution for angular2-json-schema-form to implement the cascades

Anthropic commented 6 years ago

@jasminecjc angular2-json-schema-form is an unrelated project.