Class Repeater

Generates HTML from a set of data. Use this control to generate lists of items.

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(options?: any): Repeater

Creates a new Repeater control.

constructor

Parameters

  • options?: any optional

    An object that contains one or more property/value pairs to apply to the new Repeater. Each property of the options object corresponds to one of the object's properties or events. Event names must begin with "on".

Returns

Repeater

Properties

public data: List

Gets or sets the List that provides the Repeater with items to display.

public element: HTMLElement

Gets the DOM element that hosts the Repeater.

public length: number

Gets the number of items in the Repeater control.

public template: Template

Gets or sets a WinJS.Binding.Template or custom rendering function that defines the HTML of each item within the Repeater.

Methods

public addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean)

Registers an event handler for the specified event.

Parameters

  • eventName: string

    The name of the event to handle.

  • eventHandler: Function

    The event handler function to associate with the event.

  • useCapture?: boolean optional

    Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase.

public dispatchEvent(type: string, eventProperties: any): boolean

Raises an event of the specified type and with additional properties.

Parameters

  • type: string

    The type (name) of the event.

  • eventProperties: any

    The set of additional properties to be attached to the event object when the event is raised.

Returns

boolean

true if preventDefault was called on the event, otherwise false.

public dispose()

Releases resources held by this Repeater. Call this method when the Repeater is no longer needed. After calling this method, the Repeater becomes unusable.

public elementFromIndex(index: number): HTMLElement

Returns the HTML element for the item at the specified index.

Parameters

  • index: number

    The index of the item.

Returns

HTMLElement

The DOM element for the specified item.

public onitemchanged(eventInfo: CustomEvent)

Raised after an item in the Repeater control's data source changes and after the corresponding DOM element has been updated.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.index, detail.key, detail.newElement, detail.newItem, detail.newValue, detail.oldElement, detail.oldItem, detail.oldValue, detail.setPromise.

public onitemchanging(eventInfo: CustomEvent)

Raised after an item in the Repeater control's data source changes but before the corresponding DOM element has been updated.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.index, detail.key, detail.newElement, detail.newItem, detail.newValue, detail.oldElement, detail.oldItem, detail.oldValue, detail.setPromise.

public oniteminserted(eventInfo: CustomEvent)

Raised after an item has been added to the Repeater control's data source and after the corresponding DOM element has been added.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElement, detail.index, detail.key, detail.value.

public oniteminserting(eventInfo: CustomEvent)

Raised after an item has been added to the Repeater control's data source but before the corresponding DOM element has been added.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElement, detail.index, detail.key, detail.value.

public onitemmoved(eventInfo: CustomEvent)

Raised after an item has been moved from one index to another in the Repeater control's data source and after the corresponding DOM element has been moved.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElement, detail.index, detail.key, detail.oldIndex, detail.newIndex.

public onitemmoving(eventInfo: CustomEvent)

Raised after an item has been moved from one index to another in the Repeater control's data source but before the corresponding DOM element has been moved.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElement, detail.index, detail.key, detail.oldIndex, detail.newIndex.

public onitemremoved(eventInfo: CustomEvent)

Raised after an item has been moved from one index to another in the Repeater control's data source and after the corresponding DOM element has been moved.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElement, detail.index, detail.item, detail.setPromise.

public onitemremoving(eventInfo: CustomEvent)

Raised after an item has been removed from the Repeater control's data source but before the corresponding DOM element has been removed.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElement, detail.index, detail.item, detail.setPromise.

public onitemsloaded(eventInfo: CustomEvent)

Raised when the Repeater has finished loading a new set of data. This event is only fired on construction. This event is only raised when the Repeater is constructed or its data source or template changes.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event.

public onitemsreloaded(eventInfo: CustomEvent)

Raised after the Repeater control's underlying data has been updated and after the updated HTML has been reloaded.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElements.

public onitemsreloading(eventInfo: CustomEvent)

Raised after the Repeater control's underlying data has been updated but before the updated HTML has been reloaded.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElements, detail.setPromise.

public removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean)

Removes an event handler that the addEventListener method registered.

Parameters

  • eventName: string

    The name of the event that the event handler is registered for.

  • eventCallback: Function

    The event handler function to remove.

  • useCapture?: boolean optional

    Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler.