ListBox component allows the user to select values from the predefined list of values.
<ejs-listbox :dataSource='data'></ejs-listbox>
boolean
If ‘allowDragAndDrop’ is set to true, then you can perform drag and drop of the list item. ListBox contains same ‘scope’ property enables drag and drop between multiple ListBox.
Defaults to false
boolean
To enable the filtering option in this component.
Filter action performs when type in search box and collect the matched item through filtering
event.
If searching character does not match, noRecordsTemplate
property value will be shown.
Defaults to false
string
Sets the CSS classes to root element of this component, which helps to customize the complete styles.
Defaults to ”
Object
[]
| DataManager
| string[]
| number[]
| boolean[]
Accepts the list items either through local or remote service and binds it to the component.
It can be an array of JSON Objects or an instance of
DataManager
.
Defaults to []
boolean
Enable or disable persisting component’s state between page reloads. If enabled, following list of states will be persisted.
Defaults to false
boolean
Enable or disable rendering component in right to left direction.
Defaults to false
boolean
Specifies a value that indicates whether the component is enabled or not.
Defaults to true
FieldSettingsModel
The fields
property maps the columns of the data table and binds the data to the component.
groupBy - Group the list items with it’s related items by mapping groupBy field.
<input type="text" tabindex="1" id="list"> </input>
let customers: DropDownList = new DropDownList({
dataSource:new DataManager({ url:'http://js.syncfusion.com/demos/ejServices/Wcf/Northwind.svc/' }),
query: new Query().from('Customers').select(['ContactName', 'CustomerID']).take(5),
fields: { text: 'ContactName', value: 'CustomerID' },
placeholder: 'Select a customer'
});
customers.appendTo("#list");
Defaults to {text: null, value: null, iconCss: null, groupBy: null}
string
Accepts the value to be displayed as a watermark text on the filter bar.
Defaults to null
string
Determines on which filter type, the component needs to be considered on search action.
The FilterType
and its supported data types are
FilterType |
Description |
Supported Types |
StartsWith |
Checks whether a value begins with the specified value. |
String |
EndsWith |
Checks whether a value ends with specified value. |
String |
Contains |
Checks whether a value contains with specified value. |
String |
The default value set to StartsWith
, all the suggestion items which contain typed characters to listed in the suggestion popup.
Defaults to ‘StartsWith’
number
| string
Sets the height of the ListBox component.
Defaults to ”
string
Accepts the template design and assigns it to each list item present in the popup.
We have built-in template engine
which provides options to compile template string into a executable function.
For EX: We have expression evolution as like ES6 expression string literals.
Defaults to null
string
Overrides the global culture and localization value for this component. Default global culture is ‘en-US’.
Defaults to ‘en-US’
number
Sets limitation to the value selection. based on the limitation, list selection will be prevented.
Defaults to 1000
string
Accepts the template design and assigns it to popup list of component when no data is available on the component.
Defaults to ‘No records found’
Query
Accepts the external Query
which will execute along with the data processing.
Defaults to null
string
Defines the scope value to group sets of draggable and droppable ListBox. A draggable with the same scope value will be accepted by the droppable.
Defaults to ”
Specifies the selection mode and its type.
Defaults to { mode: ‘Multiple’, type: ‘Default’ }
string
Specifies the sortOrder
to sort the data source. The available type of sort orders are
None
- The data source is not sorting.Ascending
- The data source is sorting with ascending order.Descending
- The data source is sorting with descending order.Defaults to null
Specifies the toolbar items and its position.
Defaults to { items: [], position: ‘Right’ }
string[]
| number[]
| boolean[]
Sets the specified item to the selected state or gets the selected item in the ListBox.
Defaults to []
Adds a new item to the list. By default, new item appends to the list as the last item, but you can insert based on the index parameter.
Parameter | Type | Description |
---|---|---|
items | obj[] | obj |
Specifies an array of JSON data or a JSON data. |
itemIndex (optional) | number |
Specifies the index to place the newly added item in the list. |
Returns void
This method is used to enable or disable the items in the ListBox based on the items and enable argument.
Parameter | Type | Description |
---|---|---|
items | string[] |
Text items that needs to be enabled/disabled. |
enable (optional) | boolean |
Set true /false to enable/disable the list items. |
isValue (optional) | boolean |
Set true if items parameter is a array of unique values. |
Returns void
To filter the data from given data source by using query.
Parameter | Type | Description |
---|---|---|
dataSource | Object[] | DataManager | string[] | number[] | boolean[] | Set the data source to filter. |
|
query (optional) | Query |
Specify the query to filter the data. |
fields (optional) | FieldSettingsModel |
Specify the fields to map the column in the data table. |
Returns void
Gets the data Object that matches the given value.
Parameter | Type | Description |
---|---|---|
value | string | number | boolean |
Specifies the value of the list item. |
Returns Object | string | number | boolean
Gets the array of data Object that matches the given array of values.
Parameter | Type | Description |
---|---|---|
value | string[] | number[] | boolean[] |
Specifies the array value of the list item. |
Returns *Object[]*
Gets the updated dataSource in ListBox.
Returns *Object[]* | string[] | boolean[] | number[]
Gets all the list items bound on this component.
Returns Element[]
Returns the sorted Data in ListBox.
Returns *Object[]* | string[] | boolean[] | number[]
Moves all the values from one ListBox to the scoped ListBox.
Parameter | Type | Description |
---|---|---|
targetId (optional) | string |
Specifies the scoped ListBox ID. |
index (optional) | number |
Specifies the index to where the items moved. |
Returns void
Moves the given value(s) / selected value(s) downwards.
Parameter | Type | Description |
---|---|---|
value (optional) | string[] | number[] | boolean[] |
Specifies the value(s). |
Returns void
Moves the given value(s) / selected value(s) to the given / default scoped ListBox.
Parameter | Type | Description |
---|---|---|
value (optional) | string[] | number[] | boolean[] |
Specifies the value or array value of the list item. |
index (optional) | number |
Specifies the index. |
targetId (optional) | string |
Specifies the target id. |
Returns void
Moves the given value(s) / selected value(s) upwards.
Parameter | Type | Description |
---|---|---|
value (optional) | string[] | number[] | boolean[] |
Specifies the value(s). |
Returns void
Removes a item from the list. By default, removed the last item in the list, but you can remove based on the index parameter.
Parameter | Type | Description |
---|---|---|
items (optional) | Object`[]` | Object | string | boolean | number | string[] | boolean[] | number[] | Specifies an array of JSON data or a JSON data. |
|
itemIndex (optional) | number |
Specifies the index to remove the item from the list. |
Returns void
Removes a item from the list. By default, removed the last item in the list, but you can remove based on the index parameter.
Parameter | Type | Description |
---|---|---|
items (optional) | obj[] | obj |
Specifies an array of JSON data or a JSON data. |
itemIndex (optional) | number |
Specifies the index to remove the item from the list. |
Returns void
Based on the state parameter, entire list item will be selected/deselected.
Parameter | Type | Description |
---|---|---|
state (optional) | boolean |
Set true /false to select/un select the entire list items. |
Returns void
Based on the state parameter, specified list item will be selected/deselected.
Parameter | Type | Description |
---|---|---|
items | string[] |
Array of text value of the item. |
state (optional) | boolean |
Set true /false to select/un select the list items. |
isValue (optional) | boolean |
Set true if items parameter is a array of unique values. |
Returns void
EmitType<Object>
Triggers before fetching data from the remote server.
EmitType<Object>
Triggers after data is fetched successfully from the remote server.
EmitType<Object>
Triggers when the data fetch request from the remote server fails.
Triggers before dropping the list item on another list item.
EmitType<BeforeItemRenderEventArgs>
Triggers while rendering each list item.
EmitType<ListBoxChangeEventArgs>
Triggers while select / unselect the list item.
EmitType<Object>
Triggers when the component is created.
EmitType<Object>
Triggers when the component is destroyed.
Triggers while dragging the list item.
Triggers after dragging the list item.
Triggers before dropping the list item on another list item.
EmitType<FilteringEventArgs>
Triggers on typing a character in the component.