SitedList
- Object
- SitedObject
- SitedList
Remarks
SitedList is a subclass of SitedObject that adds array-like collection behavior. When you add or remove items from SitedList it fires change notifications, telling listeners that the list has changed. This is used by the binding engine to update the user interface when the contents of a list changes.
Typically, SitedList contains a list of SitedObjects, though it may contain other kinds of objects, notably strings or numbers.
See Also
DataListEvents
ID_listChanged | Event handler called when the list changes. |
Methods
add | Adds an item to the list. Notifies listeners of the change. |
addEventHandler (inherited from SitedObject) | Adds a delegate to be called when the specified eventId occurs on this object. |
addOrFlattenItem | |
contains | Tests if this list contains the specified object. |
equals (inherited from SitedObject) | Tests if two objects are equal. |
fireEventHandler (inherited from SitedObject) | Invokes any user event handlers registered for a particular event using SitedObject.addEventHandler(). |
flatten | Creates a SitedList from the list of arguments, expanding any nested arrays into individual elements, recursively. |
getBindingStatus (inherited from SitedObject) | Provides debugging information on bindings for this object. |
getInternalArray | Gets the JavaScript Array object used internally to store the list's items. |
getLength | Gets the number of items in the list. |
getPathValue (inherited from SitedObject) | Traverses a binding path and returns the value at the end of it. |
getPropertyInfo (inherited from SitedObject) | Gets information on a property. |
getSite (inherited from SitedObject) | Gets this object's site. |
getValue | (Override) Gets the value of a property on this object. |
indexOf | Gets the index of the specified object. |
insert | Inserts an item in the list at the specified index. Notifies listeners of the change. |
onSetValue | (Override) Called by SitedObject.setValue() when a property value is set on this object. |
onSited (inherited from SitedObject) | Called when this object is sited. |
onUnsited (inherited from SitedObject) | Called when this object is about to lose its site. |
onValueSited (inherited from SitedObject) | Called when an object is sited within this object. |
onValueUnsited (inherited from SitedObject) | Called when an object is about to be unsited in this. |
remove | Removes the specified object from the list. Notifies listeners of the change. |
removeAt | Removes the item at the specified index. Notifies listeners of the change. |
removeEventHandler (inherited from SitedObject) | Remove an existing delegate from the list of delegates for the specified event. |
setInitialValues (inherited from SitedObject) | Sets multiple property values on an object (during initialization only) |
setItems | Wholesale replacement of this lists contents with another list's contents. Fires change notifications. |
setPathValue (inherited from SitedObject) | Traverses a binding path and sets the value at the end of it. |
setValue | (Override) Sets the value of a property on this object. |
toArray | Returns a copy of this list's items as an array. |
toString (inherited from SitedObject) | Returns a string representation of this object. |
SitedList add method
JavaScript
sitedList.add(newVal)
SitedList addOrFlattenItem static method
JavaScript
SitedList.addOrFlattenItem(list,item,curIndex)
SitedList contains method
JavaScript
var boolVal = sitedList.contains(obj)
Returns
SitedList flatten static method
JavaScript
SitedList.flatten()
SitedList getInternalArray method
JavaScript
var array = sitedList.getInternalArray()
Remarks
Returns
SitedList getLength method
JavaScript
var intVal = sitedList.getLength()
Returns
SitedList getValue method (override)
JavaScript
var obj = sitedList.getValue(indexOrId)
Remarks
Extends SitedObject.getValue() to support both integer index access.
If passed an integer index, it returns the item at that index, or null if the index is out of bounds.
Otherwise, if passed a propertyId, the ID can be one of the properties associated with the list, e.g. ID_length to return the length of the list.
Returns
Example
To get the first entry in a list, use:
var mylist = new SitedList('abc'); alert(mylist.getValue(0)); // shows 'abc' in an alert box
Base Implementation
SitedList ID_listChanged event
JavaScript
sitedList.addEventHandler(ID_listChanged, new Delegate(obj, func))
Xml
<j:SitedList listChanged="alert('listChanged happened')" ... >
Remarks
This event is fired when just after an item has beeen added to, removed from, or replaced in the list.
The eventArgs for ID_listChanged is a JavaScript object with the following properties:
Property | Description |
eventId | The value ID_listChanged. |
reason | Either ID_itemInserted, ID_itemRemoved or ID_itemReplaced. |
index | The index in the list where the change is taking place. |
oldValue | for ID_itemRemoved or ID_itemReplaced, the item in the list being removed or replaced. |
newValue | For ID_itemInserted and or ID_itemReplaced, the incoming value that is being inserted. |
Example
The following JavaScript code:
// define an event handler function printEvent(sender, eventArgs) { Diagnostics.write(eventArgs.reason + " " + eventArgs.index); } // create a list var mylist = new SitedList(); // add an event handler mylist.addEventHandler(ID_listChanged, new Delegate(null, printEvent)); // change the list mylist.add("item 1"); mylist.add("item 2"); mylist.removeAt("0");
prints this in the Jitsu inspector pane:
itemInserted 0 itemInserted 1 itemRemoved 0
SitedList indexOf method
JavaScript
var intVal = sitedList.indexOf(obj)
Returns
SitedList insert method
JavaScript
sitedList.insert(newVal,index)
SitedList onSetValue method (override)
JavaScript
sitedList.onSetValue(propertyId,oldVal,newVal,notificationSource)
Remarks
Base Implementation
Overriden In
SitedList remove method
JavaScript
var intVal = sitedList.remove(obj)
Returns
SitedList removeAt method
JavaScript
sitedList.removeAt(index)
SitedList setItems method
JavaScript
sitedList.setItems(items)
Remarks
items
must be an array.SitedList setValue method (override)
JavaScript
sitedList.setValue(index,value)
Remarks
Example
To replace the first entry in a list, use:
var mylist = new SitedList('abc'); mylist.setValue(0, 'def'); // replaces 'abc'
Base Implementation
SitedList toArray method
JavaScript
sitedList.toArray()