LayerListViewModel

require(["esri/widgets/LayerList/LayerListViewModel"], function(LayerListVM) { /* code goes here */ });
Class: esri/widgets/LayerList/LayerListViewModel
Inheritance: LayerListViewModel Accessor
Since: ArcGIS API for JavaScript 4.2

Provides the logic for the LayerList widget.

See also:

Constructors

new LayerListViewModel(properties)
Parameter:
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
NameTypeSummaryClass
String

The name of the class.

more details
more detailsAccessor
Function

Specifies a function that accesses each ListItem.

more details
more detailsLayerListViewModel
Collection<ListItem>

A collection of ListItems representing operational layers.

more details
more detailsLayerListViewModel
String

The view model's state.

more details
more detailsLayerListViewModel
MapView | SceneView

The view from which the widget will operate.

more details
more detailsLayerListViewModel

Property Details

declaredClassStringreadonly inherited
Since: ArcGIS API for JavaScript 4.7

The name of the class. The declared class name is formatted as esri.folder.className.

listItemCreatedFunctionFunction
Since: ArcGIS API for JavaScript 4.4

Specifies a function that accesses each ListItem. Each list item can be modified according to its modifiable propeties. Actions can be added to list items using the actionsSections property of the ListItem.

Example:
layerListViewModel.listItemCreatedFunction = function (event) {

   // The event object contains properties of the
   // layer in the LayerList widget.
   var item = event.item;

   if (item.title === "US Demographics") {
     // open the list item in the LayerList
     item.open = true;
     // change the title to something more descriptive
     item.title = "Population by county";
     // set an action for zooming to the full extent of the layer
     item.actionsSections = [[{
       title: "Go to full extent",
       className: "esri-icon-zoom-out-fixed",
       id: "full-extent"
     }]];
   }
});
operationalItemsCollection<ListItem>readonly

A collection of ListItems representing operational layers.

stateStringreadonly

The view model's state.

Known Values: ready | disabled

Default Value:disabled

The view from which the widget will operate.

Method Overview

NameReturn TypeSummaryClass

Triggers the trigger-action event and executes the given action.

more details
more detailsLayerListViewModel

Method Details

triggerAction(action, item)

Triggers the trigger-action event and executes the given action.

Parameters:
action Action

The action to execute.

An item associated with the action.

Event Overview

NameTypeSummaryClass
{action: Action,item: ListItem}

Fires after the user clicks on an action inside the LayerList widget.

more details
more detailsLayerListViewModel

Event Details

trigger-action

Fires after the user clicks on an action inside the LayerList widget. This event may be used to define a custom function to execute when particular actions are clicked.

Properties:
action Action

The action clicked by the user.

An item associated with the action.

Searching...

API Reference search results

NameTypeModule

There were no match results from your search criteria.