Search results

ListView

Represents the EJ2 ListView control.

<div id="listview">
<ul>
<li>Favorite</li>
<li>Documents</li>
<li>Downloads</li>
</ul>
</div>
  var listviewObject = new ListView({});
  listviewObject.appendTo("#listview");

Properties

animation

AnimationSettings

The animation property provides an option to apply the different animations on the ListView component.

Defaults to { effect: ‘SlideLeft’, duration: 400, easing: ‘ease’ }

checkBoxPosition

checkBoxPosition

The checkBoxPosition is used to set the position of check box in a list item. By default, the checkBoxPosition is Left, which will appear before the text content in a list item.

Defaults to ‘Left’

cssClass

string

The cssClass property is used to add a user-preferred class name in the root element of the ListView, using which we can customize the component (both CSS and functionality customization)

Defaults to

dataSource

Object[] | string[] | number[] | DataManager

The dataSource provides the data to render the ListView component which is mapped with the fields of ListView.

Defaults to []

enable

boolean

If enable set to true, the list items are enabled. And, we can disable the component using this property by setting its value as false.

Defaults to true

enableHtmlSanitizer

boolean

If enableHtmlSanitizer set to true, allows the cross-scripting site.

Defaults to false

enablePersistence

boolean

Enable or disable persisting component’s state between page reloads.

Defaults to false

enableRtl

boolean

Enable or disable rendering component in right to left direction.

Defaults to false

enableVirtualization

boolean

If enableVirtualization set to true, which will increase the ListView performance, while loading a large amount of data.

Defaults to false

fields

FieldSettingsModel

The fields is used to map keys from the dataSource which extracts the appropriate data from the dataSource with specified mapped with the column fields to render the ListView.

Defaults to ListBase.defaultMappedFields

groupTemplate

string

The ListView has an option to custom design the group header title with the help of groupTemplate property.

Defaults to null

headerTemplate

string

The ListView has an option to custom design the ListView header title with the help of headerTemplate property.

Defaults to null

headerTitle

string

The headerTitle is used to set the title of the ListView component.

Defaults to ""

height

number | string

Defines the height of the ListView component which accepts both string and number values.

Defaults to

htmlAttributes

Object

The htmlAttributes allows additional attributes such as id, class, etc., and accepts n number of attributes in a key-value pair format.

Defaults to {}

locale

string

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

Defaults to

query

Query

The query is used to fetch the specific data from dataSource by using where and select keywords.

Defaults to null

showCheckBox

boolean

If showCheckBox set to true, which will show or hide the checkbox.

Defaults to false

showHeader

boolean

If showHeader set to true, which will show or hide the header of the ListView component.

Defaults to false

showIcon

boolean

If showIcon set to true, which will show or hide the icon of the list item.

Defaults to false

sortOrder

string

The sortOrder is used 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’

template

string

The ListView component supports to customize the content of each list items with the help of template property.

Defaults to null

width

number | string

Defines the width of the ListView component which accepts both string and number values.

Defaults to

Methods

addEventListener

Adds the handler to the given event listener.

Returns void

addItem

Adds the new list item(s) to the current ListView. To add a new list item(s) in the ListView, we need to pass the data as an array of items that need to be added and fields as the target item to which we need to add the given item(s) as its children. For example fields: { text: ‘Name’, tooltip: ‘Name’, id:‘id’}

Returns void

appendTo

Appends the control within the given HTML element

Parameter Type Description
selector (optional) string | HTMLElement Target element where control needs to be appended

Returns void

back

Switches back from the navigated sub list item.

Returns void

checkAllItems

Checks all the unchecked items in the ListView.

Returns void

checkItem

Checks the specific list item by passing the unchecked fields as an argument to this method.

Parameter Type Description
item Fields | HTMLElement | Element It accepts Fields or HTML list element as an argument.

Returns void

dataBind

When invoked, applies the pending property changes immediately to the component.

Returns void

destroy

It is used to destroy the ListView component.

Returns void

disableItem

Disables the list items by passing the Id and text fields.

Parameter Type Description
item Fields | HTMLElement | Element We can pass element Object or Fields as Object with ID and Text fields.

Returns void

enableItem

Enables the disabled list items by passing the Id and text fields.

Parameter Type Description
item Fields | HTMLElement | Element We can pass element Object or Fields as Object with ID and Text fields.

Returns void

findItem

Finds out an item details from the current list.

Parameter Type Description
item Fields | HTMLElement | Element We can pass element Object or Fields as Object with ID and Text fields.

Returns SelectedItem

getRootElement

Returns the route element of the component

Returns HTMLElement

getSelectedItems

Gets the details of the currently selected item from the list items.

Returns SelectedItem | SelectedCollection | UISelectedItem | NestedListData

hideItem

Hides an list item from the ListView.

Parameter Type Description
item Fields | HTMLElement | Element We can pass element Object or Fields as Object with ID and Text fields.

Returns void

refresh

Applies all the pending property changes and render the component again.

Returns void

refreshItemHeight

Refresh the height of the list item.

Returns void

removeEventListener

Removes the handler from the given event listener.

Returns void

removeItem

Removes the list item from the data source based on a passed element like fields: { text: ‘Name’, tooltip: ‘Name’, id:‘id’}

Parameter Type Description
item Fields | HTMLElement | Element We can pass element Object or Fields as Object with ID and Text fields.

Returns void

removeMultipleItems

Removes multiple items from the ListView by passing the array of elements or array of field objects.

Parameter Type Description
item HTMLElement[] | Element[] | Fields[] We can pass array of elements or array of field Object with ID and Text fields.

Returns void

render

Initializes the ListView component rendering.

Returns void

selectItem

Selects the list item from the ListView by passing the elements or field object.

Parameter Type Description
item Fields | HTMLElement | Element We can pass element Object or Fields as Object with ID and Text fields.

Returns void

selectMultipleItems

Selects multiple list items from the ListView.

Parameter Type Description
item Fields[] | HTMLElement[] | Element[] We can pass array of
elements or array of fields Object with ID and Text fields.

Returns void

showItem

Shows the hide list item from the ListView.

Parameter Type Description
item Fields | HTMLElement | Element We can pass element Object or Fields as Object with ID and Text fields.

Returns void

uncheckAllItems

Uncheck all the checked items in ListView.

Returns void

uncheckItem

Uncheck the specific list item by passing the checked fields as an argument to this method.

Parameter Type Description
item Fields | HTMLElement | Element It accepts Fields or HTML list element as an argument.

Returns void

Inject

Dynamically injects the required modules to the component.

Returns void

Events

actionBegin

EmitType<Object>

Triggers when every ListView action starts.

actionComplete

EmitType<Object>

Triggers when every ListView actions completed.

actionFailure

EmitType<Object>

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

select

EmitType<SelectEventArgs>

Triggers when we select the list item in the component.