Creates a WinJS.Binding.List object.
Syntax
var object = new WinJS.Binding.List(list, options);
Members
The List object has these types of members:
Events
The List object has these events.
| Event | Description |
|---|---|
| onitemchanged |
An item in the list has changed its value. |
| oniteminserted |
A new item has been inserted into the list. |
| onitemmutated |
An item has been mutated. This event occurs as a result of calling the notifyMutated method. |
| onitemremoved |
An item has been removed from the list. |
| onreload |
The list has been refreshed. Any references to items in the list may be incorrect |
Methods
The List object has these methods.
| Method | Description |
|---|---|
| addEventListener |
Adds an event listener. |
| concat |
Returns a new list consisting of a combination of two arrays. |
| createFiltered |
Creates a live filtered projection over this list. As the list changes, the filtered projection reacts to those changes and may also change. |
| createGrouped |
Creates a live grouped projection over this list. As the list changes, the grouped projection reacts to those changes and may also change. The grouped projection sorts all the elements of the list to be in group-contiguous order. The grouped projection also contains a .groups property, which is a List representing the groups that were found in the list. |
| createSorted |
Creates a live sorted projection over this list. As the list changes, the sorted projection reacts to those changes and may also change. |
| dispose |
isconnects this WinJS.Binding.List projection from its underlying WinJS.Binding.List. This is important only if they have different lifetimes. |
| every |
Checks whether the specified callback function returns true for all elements in a list. |
| filter |
Returns the elements of a list that meet the condition specified in a callback function. |
| forEach |
Calls the specified callback function for each element in a list. |
| getAt |
Gets the value at the specified index. |
| getItem |
Gets a key/data pair for the specified list index. |
| getItemFromKey |
Gets a key/data pair for the list item key specified. |
| indexOf |
Gets the index of the first occurrence of the specified value in a list. |
| indexOfKey |
Gets the index of the first occurrence of a key in a list. |
| join |
Returns a string consisting of all the elements of a list separated by the specified separator string. |
| lastIndexOf |
Gets the index of the last occurrence of the specified value in a list. |
| List |
Creates a List object. |
| map |
Calls the specified callback function on each element of a list, and returns an array that contains the results. |
| move |
Moves the value at index to the specified position. |
| notifyMutated |
Forces the list to send a itemmutated notification to any listeners for the value at the specified index. |
| notifyReload |
Forces the list to send a reload notification to any listeners. |
| pop |
Removes the last element from a list and returns it. |
| push |
Appends new element(s) to a list, and returns the new length of the list. |
| reduce |
Accumulates a single result by calling the specified callback function for all elements in a list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
| reduceRight |
Accumulates a single result by calling the specified callback function for all elements in a list, starting with the last member of the list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
| removeEventListener |
Removes an event listener. |
| reverse |
Returns a list with the elements reversed. This method reverses the elements of a list object in place. It does not create a new list object during execution. |
| setAt |
Replaces the value at the specified index with a new value. |
| shift |
Removes the first element from a list and returns it. |
| slice |
Extracts a section of a list and returns a new list. |
| some |
Checks whether the specified callback function returns true for any element of a list. |
| sort |
Returns a list with the elements sorted. This method sorts the elements of a list object in place. It does not create a new list object during execution. |
| splice |
Removes elements from a list and, if necessary, inserts new elements in their place, returning the deleted elements. |
| unshift |
Appends new element(s) to a list, and returns the new length of the list. |
Properties
The List object has these properties.
| Property | Description |
|---|---|
|
Gets the data source for the list. The only purpose of this property is to adapt a List to the data model that is used by ListView and FlipView. | |
|
Gets a List that is a projection of the groups that were identified in this list. This property is available only for GroupsListProjection objects. | |
|
Gets or sets the length of the list, which is an integer value one higher than the highest element defined in the list. |
Examples
The following code shows how to connect a List to a ListView object. The DIV object displays the members of the list. Note that you must use the list's dataSource property to bind to the itemDataSource property of the ListView.
You can also connect a List to a FlipView object, which displays each member of the list separately. You can see how it works by changing data-win-control="WinJS.UI.ListView" to data-win-control="WinJS.UI.FlipView".
For more information about using ListViews and FlipViews with Lists, see Quickstart: Adding a ListView and Quickstart: Adding a FlipView.
<div id="listDiv" data-win-control="WinJS.UI.ListView" data-win-options="{ itemDataSource : dataList.dataSource }"> </div> <script type="text/javascript"> var dataArray = [ { name: "Marley", species: "dog" }, { name: "Lola", species: "cat" }, { name: "Leo", species: "dog" }, { name: "Izzy", species: "cat" }, { name: "Ziggy", species: "cat" }, { name: "Ruby", species: "dog" } ]; var dataList = new WinJS.Binding.List(dataArray); WinJS.UI.processAll(); </script>
Requirements
|
Namespace |
WinJS.Binding |
|---|---|
|
Library |
|
Build date: 12/5/2012