Class: DynamicList<DataType>
Defined in: src/garminsdk/components/list/DynamicList.ts:11
A list that handles dynamically adding and removing list items from an HTML element.
Type Parameters
Type Parameter |
---|
DataType extends DynamicListData |
Constructors
Constructor
new DynamicList<
DataType
>(data
,itemsContainer
,renderItem
,sortItems?
):DynamicList
<DataType
>
Defined in: src/garminsdk/components/list/DynamicList.ts:46
Creates a new instance of DynamicList.
Parameters
Parameter | Type | Description |
---|---|---|
data | SubscribableArray <DataType > | An array of data items to display in this list. |
itemsContainer | Element | The Element to which this list's items will be rendered as children. |
renderItem | (data , index ) => VNode | A function that used to render this list's items. The function is called for every list item that is added to this list. If the root node returned by the function is a DisplayComponent, then its destroy() method will be called when the item is removed from this list. |
sortItems? | (a , b ) => number | A function to sort data items before rendering them. The function should return a negative number if the first item should be rendered before the second, a positive number if the first item should be rendered after the second, or zero if the two items' relative order does not matter. If not defined, items will be rendered in the order in which they appear in the data item array. |
Returns
DynamicList
<DataType
>
Properties
visibleItemCount
readonly
visibleItemCount:Subscribable
<number
>
Defined in: src/garminsdk/components/list/DynamicList.ts:16
The number of visible items in this list.
Methods
destroy()
destroy():
void
Defined in: src/garminsdk/components/list/DynamicList.ts:463
Destroys this list.
Returns
void
forEachComponent()
forEachComponent<
T
>(fn
,visibleOnly
,sortedOrder
):void
Defined in: src/garminsdk/components/list/DynamicList.ts:174
Iterates over each rendered component and executes a callback function.
Type Parameters
Type Parameter |
---|
T extends DisplayComponent <any , []> |
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
fn | (component , index ) => void | undefined | The callback function to execute for each component. The function should take two arguments: the first argument is the iterated component, and the second argument is the index of the component in the iteration. |
visibleOnly | boolean | false | Whether to only iterate over components whose associated data items have their visibility flags set to true . Defaults to false . |
sortedOrder | boolean | false | Whether to iterate over components in sorted order instead of the order in which their associated data items appear in the data array. Defaults to false . |
Returns
void
getRenderedItem()
getRenderedItem(
index
):undefined
|NodeInstance
Defined in: src/garminsdk/components/list/DynamicList.ts:161
Gets the rendered instance of a data item in this list.
Parameters
Parameter | Type | Description |
---|---|---|
index | number | The index of the data item for which to get the rendered instance. |
Returns
undefined
| NodeInstance
The rendered instance of the specified data item, or undefined
if index
is out of bounds.
indexOfSortedIndex()
indexOfSortedIndex(
sortedIndex
):number
Defined in: src/garminsdk/components/list/DynamicList.ts:126
Gets the data item index of a sorted index.
Parameters
Parameter | Type | Description |
---|---|---|
sortedIndex | number | A sorted index. |
Returns
number
The index of the data item that is sorted to the specified index, or -1
if the sorted index is out of bounds.
indexOfSortedVisibleIndex()
indexOfSortedVisibleIndex(
sortedVisibleIndex
):number
Defined in: src/garminsdk/components/list/DynamicList.ts:136
Gets the data item index of a sorted index after hidden items have been excluded.
Parameters
Parameter | Type | Description |
---|---|---|
sortedVisibleIndex | number | A sorted index after hidden items have been excluded. |
Returns
number
The index of the data item that is sorted to the specified index after hidden items have been excluded,
or -1
if the sorted index is out of bounds.
sortedIndexOfData()
sortedIndexOfData(
data
):number
Defined in: src/garminsdk/components/list/DynamicList.ts:77
Gets the sorted index of a data item.
Parameters
Parameter | Type | Description |
---|---|---|
data | DataType | A data item. |
Returns
number
The index to which the specified data item is sorted, or -1
if the item is not in this list.
sortedIndexOfIndex()
sortedIndexOfIndex(
index
):number
Defined in: src/garminsdk/components/list/DynamicList.ts:68
Gets the sorted index of a data item index.
Parameters
Parameter | Type | Description |
---|---|---|
index | number | A data item index. |
Returns
number
The index to which the specified data item index is sorted, or -1
if the data index is out of bounds.
sortedVisibleIndexOfData()
sortedVisibleIndexOfData(
data
):number
Defined in: src/garminsdk/components/list/DynamicList.ts:113
Gets the sorted index of a data item after hidden items have been excluded.
Parameters
Parameter | Type | Description |
---|---|---|
data | DataType | A data item. |
Returns
number
The index to which the specified data item is sorted after hidden items have been excluded, or -1
if
the item is not in this list or is itself hidden.
sortedVisibleIndexOfIndex()
sortedVisibleIndexOfIndex(
index
):number
Defined in: src/garminsdk/components/list/DynamicList.ts:87
Gets the sorted index of a data item index after hidden items have been excluded.
Parameters
Parameter | Type | Description |
---|---|---|
index | number | A data item index. |
Returns
number
The index to which the specified data item index is sorted after hidden items have been excluded, or -1
if the data index is out of bounds or the data item whose index was given is itself hidden.
updateOrder()
updateOrder():
void
Defined in: src/garminsdk/components/list/DynamicList.ts:437
Updates the order of the rendered items in this list.
Returns
void