List Model API

Purpose

Provides methods that manage items to be presented by the List View component. The presentation of items is handled by a renderer that is responsible for turning the data into a form that can be displayed by the ui:list-view element.

Markup

The ui:list-model element represents a JSON-based list model. Refer to List Model for further information.

Client Framework 2 UI components List Model API JavaScript JavaScript

The following methods provide access to items within a model.

getItemCount()

Returns the number of items in the model.

getItem(item)

Returns the contents of the selected item.

Parameter Description Type
item The index of the item to retrieve. The value of this parameter must be between '0' (inclusive) and getItemCount() (exclusive). Integer

Events

Whenever items change, the model fires a cf2:listItemsChanged event. The following table lists its properties.

cf2:listItemsChanged
Property Description Type
target The list model that has changed. ListModel
first The index of the first item that has changed. Integer
last The index of the last item that has changed. Integer
count The number of items in the model. Integer
oldContent The old content of the items. any[]
newContent The new content of the items. any[]

Whenever items are replaced, the model fires a cf2:listItemsReplaced event. The following table lists its properties.

cf2:listItemsReplaced
Property Description Type
target The list model that has changed. ListModel
first The index of the first item that has been replaced. Integer
last The index of the last item that has been replaced. Integer
count The number of items in the model. Integer
oldContent The old content of the items. any[]
newContent The new content of the items. any[]

Whenever items are inserted, the model fires a cf2:listItemsInserted event.

cf2:listItemsInserted
Property Description Type
target The list model that was changed. ListModel
content The content of the items that have been inserted. any[]
index The index where the items have been inserted. Integer
oldCount The old number of items in the selected model. Integer
newCount The new number of items in the selected model. Integer

Whenever items are moved, the model fires a cf2:listItemsMoved event.

cf2:listItemsMoved
Property Description Type
target The list model that has changed. ListModel
first The index of the first item that has moved. Integer
last The index of the last item that has moved. Integer
content The content of the items that have moved. any[]
index The new index of the first item. Integer
count The number of items in the model. Integer

Whenever items are removed, the model fires a cf2:listItemsRemoved event.

cf2:listItemsRemoved
Property Description Type
target The list model that has changed. ListModel
content The content of the items that have been removed. any[]
index The index from where the items have been removed. Integer
oldCount The old number of items in the selected model. Integer
newCount The new number of items in the selected model. Integer

Component class

This interface class defines a type and any component that implements this interface must declare that it implements the ui:ListModelAPI type, which extends cf2:EventTarget.

<cx:component-class xmlns:cf2="http://www.volantis.com/xmlns/2009/07/cf2"
  xmlns:cx="http://www.volantis.com/xmlns/2010/07/cf2/cx"
  xmlns:ui="http://www.volantis.com/xmlns/2009/07/cf2/ui"
  implements="cf2:EventTarget"
  name="ui:ListModelAPI"
  defines="all">
</cx:component-class>

Related topics