The ListItem class represents one of the operationalItems in the LayerListViewModel. In the LayerList widget UI, the list item represents a layer displayed in the view. It provides access to the associated layer's properties, allows the developer to configure actions related to the layer, and allows the developer to add content to the item related to the layer.
To hide list items in the LayerList widget, you must set the
listMode property on the desired layers to hide
.
You cannot hide list items using this class or the LayerList class.
- See also:
Property Overview
Name | Type | Summary | Class | |
---|---|---|---|---|
Boolean | more details Whether the actions panel is open in the LayerList. | more details | ListItem | |
Collection<Collection<(ActionButton|ActionToggle)>> | more details A nested 2-dimensional collection of actions that could be triggered on the item. | more details | ListItem | |
Collection<ListItem> | more details When a layer contains sublayers, this property is a Collection of ListItem objects belonging to the given layer. | more details | ListItem | |
Boolean | more details Indicates if the children of a list item (or sublayers in a GroupLayer) can be sorted or moved/reordered. | more details | ListItem | |
String | more details Only valid when the list item represents a StreamLayer. | more details | ListItem | |
String | more details The name of the class. | more details | Accessor | |
Error | more details The Error object returned if an error occurred. | more details | ListItem | |
Boolean | more details When | more details | ListItem | |
Layer | more details The layer associated with the triggered action. | more details | ListItem | |
LayerView | more details | more details | ListItem | |
Boolean | more details Whether the layer is open in the LayerList. | more details | ListItem | |
ListItemPanel | more details Allows you to display custom content for each ListItem in the LayerList widget. | more details | ListItem | |
ListItem | more details The parent of this item | more details | ListItem | |
Boolean | more details Indicates if the list item (or layer in the map) can be sorted or moved/reordered. | more details | ListItem | |
String | more details The title of the layer. | more details | ListItem | |
Boolean | more details Value is | more details | ListItem | |
MapView|SceneView | more details The view from which the widget will operate. | more details | ListItem | |
String | more details Indicates how to manage the visibility of the children layers. | more details | ListItem | |
Boolean | more details Indicates if the ListItem is visible. | more details | ListItem | |
Boolean | more details Whether the layer is visible at the current scale or not. | more details | ListItem |
Property Details
-
actionsOpen Boolean
-
Whether the actions panel is open in the LayerList.
- Default Value:false
-
actionsSections Collection<Collection<(ActionButton|ActionToggle)>>autocast
-
A nested 2-dimensional collection of actions that could be triggered on the item.
- See also:
-
children Collection<ListItem>
-
When a layer contains sublayers, this property is a Collection of ListItem objects belonging to the given layer.
-
childrenSortable BooleanSince: ArcGIS API for JavaScript 4.16
-
Indicates if the children of a list item (or sublayers in a GroupLayer) can be sorted or moved/reordered.
- Default Value:true
Example:// disables the children of a parent list item from being sorted listItem.childrenSortable = false;
-
connectionStatus StringreadonlySince: ArcGIS API for JavaScript 4.24
-
Only valid when the list item represents a StreamLayer. Indicates the status of the stream layer connection. This overrides the updating property. When a stream layer is connected, a green circle will appear next to the list item title. When it is
disconnected
a hollow red ring will display next to the list item title.Possible Values:"connected"|"disconnected"
-
Since: ArcGIS API for JavaScript 4.7
-
The name of the class. The declared class name is formatted as
esri.folder.className
.
-
error Errorreadonly
-
The Error object returned if an error occurred.
-
Since: ArcGIS API for JavaScript 4.24
-
When
true
, hides the layer from the LayerList instance. This is an alternative to Layer.listMode, which hides a layer from all instances of LayerList that include the layer.- Default Value:false
Example:let layerList1 = new LayerList({ view, container: layerList1Container, listItemCreatedFunction: (event) => { // hides the USA - Highway layer from the // layerList1 instance of layerlist if(event.item.title === "USA - Highways") { event.item.hidden = true; } } });
-
layer Layer
-
The layer associated with the triggered action.
- Default Value:null
-
layerView LayerViewreadonly
-
-
open Boolean
-
Whether the layer is open in the LayerList.
- Default Value:false
-
panel ListItemPanelSince: ArcGIS API for JavaScript 4.7
-
Allows you to display custom content for each ListItem in the LayerList widget.
A common scenario for using ListItemPanel is to display a Legend widget within each list item. The
legend
keyword can be used in the content property of the panel to display a legend for each layer in the LayerList.Examples:// displays the legend for each layer list item const layerList = new LayerList({ view: view, listItemCreatedFunction: function(event){ const item = event.item; item.panel = { content: "legend" }; } });
// displays content from the DOM in the LayerList const layerList = new LayerList({ view: view, listItemCreatedFunction: function(event){ const item = event.item; item.panel = { content: document.getElementById("myDiv"), className: "esri-icon-chart", open: item.visible }; } });
-
parent ListItemSince: ArcGIS API for JavaScript 4.5
-
The parent of this item
- Default Value:null
-
sortable BooleanSince: ArcGIS API for JavaScript 4.16
-
Indicates if the list item (or layer in the map) can be sorted or moved/reordered.
- Default Value:true
Example:// disables the list item from being sorted listItem.sortable = false;
-
title String
-
The title of the layer.
-
updating Booleanreadonly
-
Value is
true
when the layer is updating; for example, if it is in the process of fetching data.- Default Value:false
-
The view from which the widget will operate.
-
visibilityMode Stringreadonly
-
Indicates how to manage the visibility of the children layers.
-
visible Boolean
-
Indicates if the ListItem is visible.
- Default Value:true
-
visibleAtCurrentScale Booleanreadonly
-
Whether the layer is visible at the current scale or not.
- Default Value:true
Method Overview
Name | Return Type | Summary | Class | |
---|---|---|---|---|
ListItem | more details Creates a deep clone of this object. | more details | ListItem | |
more details Adds one or more handles which are to be tied to the lifecycle of the object. | more details | Accessor |
Method Details
-
clone(){ListItem}
-
Creates a deep clone of this object.
Returns:Type Description ListItem A clone of the new ListItem instance.
-
own(handleOrHandles)inheritedSince: ArcGIS API for JavaScript 4.24
-
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.whenOnce(() => !view.updating) .then(() => { wkidSelect.disabled = false; }); handle.remove(); // Assign a handle using own() this.own(reactiveUtils.whenOnce(() => !view.updating) .then(() => { wkidSelect.disabled = false; }));
Parameter:handleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.