Class zebkit.data.ListModel
mixed with <zebkit.data.DataModel> <zebkit.EventProducer>
<zebkit.data>

List model class

Constructor:
zebkit.data.ListModel ([a])

Parameters:
  • [a] <Array>

    an array the list model has to be initialized with


Example:
     // create list model that contains three integer elements
     var l = new zebkit.data.ListModel([1,2,3]);
     l.on("elementInserted", function(list, element, index) {
         // handle list item inserted event
         ...
     })
     ...
     l.add(10)



public void add (o)
public <Boolean> contains (o)
public <Integer> count ( )
public <Object> get (i)
public <Integer> indexOf (o)
public void insert (i, o)
public void remove (o)
public void removeAll ( )
public void removeAt (i)
public <Object> setAt (i, o)


public void add (o)

Add the given item to the end of the list


Parameters:
  • o <Object>

    an item to be added

public <Boolean> contains (o)

Check if the element is in the list


Parameters:
  • o <Object>

    an element to be checked


Returns: <Boolean>

true if the element is in the list

public <Integer> count ( )

Get number of elements stored in the list


Returns: <Integer>

a number of element in the list

public <Object> get (i)

Get an item stored at the given location in the list


Parameters:
  • i <Integer>

    an item location


Returns: <Object>

a list item

public <Integer> indexOf (o)

Get position the given element is stored in the list


Parameters:
Returns: <Integer>

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

public void insert (i, o)

Insert the given element into the given position of the list


Parameters:
  • i <Integer>

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

  • o <Object>

    an element to be inserted into the list

public void remove (o)

Remove the given element from the list


Parameters:
  • o <Object>

    an element to be removed from the list

public void removeAll ( )

Remove all elements from the list model

public void 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

public <Object> setAt (i, o)

Set the new element at the given position


Parameters:
  • i <Integer>

    a position

  • o <Object>

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


Returns: <Object>

previous element that was stored at the given position


elementInserted

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

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

Parameters:
  • src <zebkit.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.on("elementRemoved", function(src, o, i) {
        ...
    });

Parameters:
  • src <zebkit.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.on("elementSet", function(src, o, p, i) {
        ...
    });

Parameters:
  • src <zebkit.data.ListModel>

    a list model that triggers the event

  • o <Object>

    an element that has been set

  • p <Object>

    a previous element

  • i <Integer>

    an index at that the element has been re-set