您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

components-listselect.asciidoc 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ---
  2. title: ListSelect
  3. order: 17
  4. layout: page
  5. ---
  6. [[components.listselect]]
  7. = ListSelect
  8. ifdef::web[]
  9. [.sampler]
  10. image:{live-demo-image}[alt="Live Demo", link="http://demo.vaadin.com/sampler/#ui/data-input/multiple-value/list-select"]
  11. endif::web[]
  12. The [classname]#ListSelect# component is list box that shows the selectable
  13. items in a vertical list. If the number of items exceeds the height of the
  14. component, a scrollbar is shown. The component allows selecting multiple values.
  15. [source, java]
  16. ----
  17. // Create the selection component
  18. ListSelect<String> select = new ListSelect<>("The List");
  19. // Add some items
  20. select.setItems("Mercury", "Venus", "Earth", ...);
  21. // Show 5 items and a scrollbar if there are more
  22. select.setRows(5);
  23. select.addValueChangeListener(event -> {
  24. Set<String> selected = event.getNewSelection();
  25. Notification.show(selected.size() + " items.");
  26. });
  27. ----
  28. The number of visible items is set with [methodname]#setRows()#.
  29. [[figure.components.listselect.basic]]
  30. .The [classname]#ListSelect# Component
  31. image::img/listselect-basic.png[width=35%, scaledwidth=50%]
  32. Common selection component features are described in
  33. <<dummy/../../../framework/components/components-selection#components.selection,"Selection Components">>.
  34. == CSS Style Rules
  35. [source, css]
  36. ----
  37. .v-select {}
  38. .v-select-select {}
  39. option {}
  40. ----
  41. The component has an overall [literal]#++v-select++# style. The native
  42. [literal]#++<select>++# element has [literal]#++v-select-select++# style. The
  43. items are represented as [literal]#++<option>++# elements.