Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically setting data set for select inputs #5928

Closed
E2dwhy opened this issue Nov 26, 2024 · 2 comments
Closed

Dynamically setting data set for select inputs #5928

E2dwhy opened this issue Nov 26, 2024 · 2 comments

Comments

@E2dwhy
Copy link

E2dwhy commented Nov 26, 2024

Is your feature request related to a problem? Please describe.
We are trying to dynamicaly set the data from the Select input

Describe the solution you'd like
We are trying to dynamicaly set the data from the Select input, that is, listening to key and key down events and update the data of the select dropdown so that we optimize the app to not load the entire dataset that is mainly about 8000 records.
Is there a way to make this work? and if yes can you guide us through?

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@seeranjeeviramavel
Copy link

Form.io's Select component allows you to fetch options dynamically from an external API. By this feature, you can optimize the data load by implementing search, filtering, sorting, and refreshing data during scrolling events.

  1. Go to Formio Builder
  2. Select the Select component, then click on the Data tab. Here, you’ll find the Data Source Type dropdown.
  3. Set the Data Source Type to URL and provide your API endpoint in the Data Source URL field.
  4. Modify the id path, value property and Item Template according to your response of the url
  5. Then save

Here is a example of dynamically set data for the select component

{
  "label": "Select",
  "widget": "choicesjs",
  "tableView": true,
  "dataSrc": "url",
  "data": {
    "url": "https://jsonplaceholder.typicode.com/users",
    "headers": [
      {
        "key": "",
        "value": ""
      }
    ]
  },
  "valueProperty": "email",
  "template": "<span>{{ item.email }}</span>",
  "validateWhenHidden": false,
  "key": "select",
  "type": "select",
  "disableLimit": false,
  "noRefreshOnScroll": false,
  "input": true
}

@lane-formio
Copy link
Contributor

@seeranjeeviramavel
Thanks for the assist!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants