Search results

ListBoxComponent

The ListBox allows the user to select values from the predefined list of values.

<ejs-listbox [dataSource]='data'></ejs-listbox>

Properties

allowDragAndDrop

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

cssClass

string

Sets the CSS classes to root element of this component, which helps to customize the complete styles.

Defaults to

dataSource

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 []

enablePersistence

boolean

Enable or disable persisting component’s state between page reloads. If enabled, following list of states will be persisted.

  1. value

Defaults to false

enableRtl

boolean

Enable or disable rendering component in right to left direction.

Defaults to false

enabled

boolean

Specifies a value that indicates whether the component is enabled or not.

Defaults to true

fields

FieldSettingsModel

The fields property maps the columns of the data table and binds the data to the component.

  • text - Maps the text column from data table for each list item.
  • value - Maps the value column from data table for each list item.
  • iconCss - Maps the icon class column from data table for each list item.
  • 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}

height

number | string

Sets the height of the ListBox component.

Defaults to

itemTemplate

any

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

locale

string

Overrides the global culture and localization value for this component. Default global culture is ‘en-US’.

Defaults to ‘en-US’

query

Query

Accepts the external Query which will execute along with the data processing.

Defaults to null

scope

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

selectionSettings

SelectionSettingsModel

Specifies the selection mode and its type.

Defaults to { mode: ‘Multiple’, type: ‘Default’ }

sortOrder

SortOrder

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 None

toolbarSettings

ToolbarSettingsModel

Specifies the toolbar items and its position.

Defaults to { items: [], position: ‘Right’ }

value

string[] | number[] | boolean[]

Sets the specified item to the selected state or gets the selected item in the ListBox.

Defaults to []

Methods

addItem

Adds a new item to the popup 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 Object`[]` &#124;Object | string | boolean | number | string[] | boolean[] | number[] | Specifies an array of JSON data or a JSON data.
itemIndex (optional) number Specifies the index to place the newly added item in the popup list.

Returns void

addItems

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 Object`[]` &#124;Object | 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

enableItems

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.

Returns void

focusIn

Sets the focus to ListBox its native method

Returns void

getDataByValue

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

getItems

Gets all the list items bound on this component.

Returns Element[]

selectAll

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

selectItems

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.

Returns void

Events

actionBegin

EmitType<Object>

Triggers before fetching data from the remote server.

actionComplete

EmitType<Object>

Triggers after data is fetched successfully from the remote server.

actionFailure

EmitType<Object>

Triggers when the data fetch request from the remote server fails.

beforeItemRender

EmitType<BeforeItemRenderEventArgs>

Triggers while rendering each list item.

change

EmitType<ListBoxChangeEventArgs>

Triggers while select / unselect the list item.

created

EmitType<Object>

Triggers when the component is created.

destroyed

EmitType<Object>

Triggers when the component is destroyed.

drag

EmitType<DragEventArgs>

Triggers while dragging the list item.

dragStart

EmitType<DragEventArgs>

Triggers after dragging the list item.

drop

EmitType<DragEventArgs>

Triggers before dropping the list item on another list item.

select

EmitType<SelectEventArgs>

Triggers while selecting the list item.