Zebra API Doc

zebra.data.ListModel Class

List model class

Constructor

zebra.data.ListModel

(
  • [a]
)

Parameters:

  • [a] Array optional

    an array the list model has to be initialized with

Example:

 // create list model that contains three integer elements
 var l = new zebra.data.ListModel([1,2,3]);

Methods

add

(
  • o
)

Add the given item to the end of the list

Parameters:

  • o Object

    an item to be added

contains

(
  • o
)
Boolean

Check if the element is in the list

Parameters:

  • o Object

    an element to be checked


Return: Boolean

true if the element is in the list

count

() Integer

Get number of elements stored in the list


Return: Integer

a number of element in the list

get

(
  • i
)
Object

Get an item stored at the given location in the list

Parameters:

  • i Integer

    an item location


Return: Object

a list item

indexOf

(
  • o
)
Integer

Get position the given element is stored in the list

Parameters:

  • o Object

    an element


Return: Integer

the element position. -1 if the element cannot be found in the list

insert

(
  • o
  • i
)

Insert the given element into the given position of the list

Parameters:

  • o Object

    an element to be inserted into the list

  • i Integer

    a position at which the element has to be inserted into the list

remove

(
  • o
)

Remove the given element from the list

Parameters:

  • o Object

    an element to be removed from the list

removeAll

()

Remove all elements from the list model

removeAt

(
  • i
)

Remove an element at the given location of the list model

Parameters:

  • i Integer

    a location of an element to be removed from the list

set

(
  • o
  • i
)
Object

Set the new element at the given position

Parameters:

  • o Object

    a new element to be set as the list element at the given position

  • i Integer

    a position


Return: Object

previous element that was stored at the given position

Events

elementInserted

Fired when a new element has been added to the list model

list.bind(function elementInserted(src, o, i) {
    ...
});

Event Parameters:

  • src zebra.data.ListModel

    a list model that triggers the event

  • o Object

    an element that has been added

  • i Integer

    an index at that the new element has been added

elementRemoved

Fired when an element has been removed from the list model

list.bind(function elementRemoved(src, o, i) {
    ...
});

Event Parameters:

  • src zebra.data.ListModel

    a list model that triggers the event

  • o Object

    an element that has been removed

  • i Integer

    an index at that the element has been removed

elementSet

Fired when an element has been re-set

list.bind(function elementSet(src, o, pe, i) {
    ...
});

Event Parameters:

  • src zebra.data.ListModel

    a list model that triggers the event

  • o Object

    an element that has been set

  • pe Object

    a previous element

  • i Integer

    an index at that the element has been re-set