question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to display text instead of Id in select drop down in lazy load?

See original GitHub issue

I have a select drop down which populates data in lazy mode from a URL. The key for the drop down is called Model_ID and is an int type. I get this key from the server and populate the drop down with this key. It works fine, however because of lazy load drop down may not have all the values so it cannot match Model_ID with corresponding Model_Name, therefore it display the Model_Id instead. How can I display Model_Name in above scenario. I have to use Model_ID as a key because it is linked to a lookup table. I have tried to use Model_Name in addition to Model_ID in MyData variable and labelProperty: 'Model_Name' in a unsuccessful attempt to achieve my goal but I guess that is not a correct way.

Code can be checked in the fiddle as well as below.

var MyData = 
{
 "Model_ID": 1863  ,//database stores int so I have to return int to link with key: Model_ID
 'Model_Name': 'Civic'//An attempt to display name
 };

Formio.createForm(document.getElementById('formio'), {
  components: [
    {
      type: 'select',
      label: 'Model',
      key: 'Model_ID',
      placeholder: 'Select your model',
      dataSrc: 'url',      
      data: {
        url: 'https://vpic.nhtsa.dot.gov/api/vehicles/getmodelsformake/honda?format=json'
      },
      valueProperty: 'Model_ID',
      labelProperty: 'Model_Name',//This may be wrong
      template: '<span>{{ item.Model_Name }}</span>',
      selectValues: 'Results'
    }
  ]
}).then((form) => {
                form.submission = {
                    data: MyData
                };});

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
randallknutsoncommented, Feb 7, 2020
1reaction
randallknutsoncommented, Feb 6, 2020

I think we still have a bug around this where if you have a valueProperty set and load data from an external url it won’t properly find the item the first time and adds it to the options as the value. I’ll bump this issue in our todo list and see if we can get it resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML select dropdownlist how to display the VALUE/ID ...
What I want to achieve is that, when I click on Value '1', the dropdownlist will display "1" instead of Yogesh Singh. Is...
Read more >
Dropdown - React Select Component - PrimeFaces
Dropdown also known as Select, is used to choose an item from a collection of ... Label of an option is used as...
Read more >
angular2-multiselect-dropdown - npm
Start using angular2-multiselect-dropdown in your project by running `npm ... Text to display as the label of select all option, Select All.
Read more >
Lazy-loading feature modules - Angular
To lazy load Angular modules, use loadChildren (instead of component ) in ... to the routes array declared in the module provided as...
Read more >
Angular 2 MultiSelect Dropdown - Cuppa Labs
Dropdown with multiselect. · Filter list. · Checkboxes. · Check all feature. · Single selection mode. · Highly configurable.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found