diff --git a/src/showcase/listbox/ListBoxDemo.js b/src/showcase/listbox/ListBoxDemo.js index c808cbb8c6..eece89c61e 100644 --- a/src/showcase/listbox/ListBoxDemo.js +++ b/src/showcase/listbox/ListBoxDemo.js @@ -94,29 +94,51 @@ import {ListBox} from 'primereact/components/listbox/ListBox';

Getting Started

-

ListBox requires a collection of options with label-value pairs, a value and an onChange event to provide the selected value.

- - +

Listbox requires a value to bind and a collection of options. There are two alternatives of how to define the options property; One way is providing a collection of SelectItem instances having label-value pairs + whereas other way is providing an array of arbitrary objects along with the optionLabel property to specify the field name of the option. SelectItem API is designed to have more + control on how the options are displayed such as grouping and disabling however in most cases an arbitrary object collection will suffice.

+ +

Options as SelectItems

+ {` - this.setState({city: e.value})} /> +var citySelectItems = [ + {label: 'New York', value: 'NY'}, + {label: 'Rome', value: 'RM'}, + {label: 'London', value: 'LDN'}, + {label: 'Istanbul', value: 'IST'}, + {label: 'Paris', value: 'PRS'} +]; `} - +
-

SelectItem API represents an option using label and value properties. Value can be a string as well as an arbirary object.

+ +{` + this.setState({city: e.value})} /> - +`} + + +

Options as any type

+ {` -let cities = [ - {label: 'New York', value: 'New York'}, - {label: 'Rome', value: 'Rome'}, - {label: 'London', value: 'London'}, - {label: 'Istanbul', value: 'Istanbul'}, - {label: 'Paris', value: 'Paris'} +var cities = [ + {name: 'New York', code: 'NY'}, + {name: 'Rome', code: 'RM'}, + {name: 'London', code: 'LDN'}, + {name: 'Istanbul', code: 'IST'}, + {name: 'Paris', code: 'PRS'} ]; `} - +
+ + +{` + this.setState({city: e.value})} /> + +`} +

Selection

Listbox allows selection of either single or multiple items whereas checkbox option displays a checkbox to indicate multiple selection.