简体   繁体   中英

Display the name instead of the value

I am using a dropdown that lists a data set.

I created a treeBoxValue variable to assign a predefined dropdown value. Thus, when I open the dropdown, the elements that contain the value of the variable treeBoxValue are checked.

My problem is that the presentation of these default values should contain the name and not the value.

Can someone help me to show only the names and not the values?

DEMO

Problem: The dropdown shows the values and not the name:(

IMG

When I open the dropdown, the values change to the name. I intend to get the names right at the beginning.

Note: If the dropdown did not open, refresh only the preview page.

Change this line:

treeBoxValue = ["1", "2"];

to this:

treeBoxValue = [1, 2];

In your Books array the field idBook is numeric.

Books = [
    {
      idBook: 1,
      name: "name1"
    },
    {
      idBook: 2,
      name: "name2"
    },
    {
      idBook: 3,
      name: "name3"
    }
  ];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM