List Item Renderer API

Purpose

Page authors can use the list view component to present the data as a list of items. 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. The list of items is managed by a model, i.e. the model provides access to these items, and generates events when the model changes.

Markup

The ui:list-item-renderer element represents a prototype-based list item renderer. Refer to the topic entitled List Item Renderer for more information.

JavaScript

renderItem(info)

Returns the presentation of the item that can be added to the corresponding list view cell. The presentation of an item depends on not just the data of the item but also the context within which it is used, e.g. its position within the model, position in the window, the total number of items in the model, the number of items displayed, etc.

The presentation of an item can be either: a DOM element, in which case the list view will simply add it as the child of the cell element, or a common UI component, in which case the list view will use the getOuter() method to retrieve the outermost element and add it as a child of the cell element.

Parameter Description Type
info

The information about the item to render. The info parameter is treated as a Map, and can contain the following information:

Parameter Description Type
item The item data as retrieved from the model. any
model The underlying list model. ListModel
view The invoking list view. ListView
index The index of the item within the model. Integer
presentation The current presentation of an item. The purpose of this parameter is to enable reuse of presentation to improve efficiency. If the presentation can be reused, then it is modified and returned; otherwise this can simply be ignored. Presentation

Events

If the renderer needs to change the rendered form of the item without changing the content, for example, because the user selected a different style, then a cf2:listItemRenderingChanged event is fired.

cf2:listItemRenderingChanged
Property Description Type
target The list item renderer that fired the event. ListItemRenderer

Component class

This interface class defines a type and any component that implements this interface must declare that it implements the ui:ListItemRendererAPI type. If it mixes in cf2:EventTarget, then it must explicitly declare that it implements that type as well.

<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"
  name="ui:ListItemRendererAPI"
  defines="all">
</cx:component-class>

Related topics