# Class MenuItem<TMenuItemProps, TMenuProps>

An item within a menus/Menu!Menu.

#### Type Parameters

- TMenuItemProps extends MenuItemProperties = MenuItemProperties
- TMenuProps extends MenuProperties = MenuProperties

#### Hierarchy (view full)

- EntityBase<TMenuItemProps>
  - MenuItem

#### Implements

- MenuItemState

#####
Index

### Constructors

constructor

### Properties

_id
_isToggled
_itemType
@eventTypes
factory

### Accessors

action
alternate
canBeToggled
description
failureMode
hideOnDisable
iconId
id
isDestroyed
isEnabled
isInitialized
isToggled
itemType
menu
root
submenu
title

### Methods

_getSerializableProperties
_initializableChildCollections
_initializeChildren
_onDestroy
_onInitialize
_postInitialize
_toPropertyDef
assignProperties
assignPropertiesAsync
destroy
finishAssignProperties
getDefault
getDefaults
getSerializableProperties
initialize
toggle
toItemUri
toJSON
create

##
Constructors

### constructor

- new MenuItem<TMenuItemProps, TMenuProps>(props?): MenuItem<TMenuItemProps, TMenuProps>

- #### Type Parameters

  - TMenuItemProps extends MenuItemProperties = MenuItemProperties
  - TMenuProps extends MenuProperties = MenuProperties

  #### Parameters

  - `Optional` props: TMenuItemProps

  #### Returns MenuItem<TMenuItemProps, TMenuProps>

  Overrides EntityBase.constructor

##
Properties

### `Protected`_id

_id: string

The unique ID for this entity. Once set, this should never change.

Inherited from EntityBase._id

### `Protected`_isToggled

_isToggled: boolean = false

### `Protected` `Readonly`_itemType

_itemType: string = ItemType.MENU_ITEM

The item type for this entity when it participates in an App.

Overrides EntityBase._itemType

### @eventTypes

@eventTypes: InitializableBaseEvents

#### Deprecated

Do not directly reference this property. Use EventNames and EventTypes helpers from @arcgis/core/Evented.

Inherited from EntityBase.@eventTypes

### `Static` factory

factory: MenuItemFactory

The factory that will be used whenever a new menu item needs to be created. Applications can supply their own factory to customize menu item creation.

##
Accessors

### action

- get action(): Action

- Indicates which action to perform when this item is selected.

  #### Returns Action

  Implementation of MenuItemState.action

- set action(value): void

- See menus/MenuItem!MenuItem.action.

  #### Parameters

  - value: Action

  #### Returns void

  Implementation of MenuItemState.action

### alternate

- get alternate(): MenuItemState

- The alternate state to set when the menu item is toggled.

  #### Returns MenuItemState

- set alternate(value): void

- #### Parameters

  - value: MenuItemState

  #### Returns void

### canBeToggled

- get canBeToggled(): boolean

- Determines whether this item supports toggling.

  #### Returns boolean

### description

- get description(): string

- A longer description explaining what the item does, typically displayed in a tooltip.

  #### Returns string

  Implementation of MenuItemState.description

- set description(value): void

- See menus/MenuItem!MenuItem.description.

  #### Parameters

  - value: string

  #### Returns void

  Implementation of MenuItemState.description

### failureMode

- get failureMode(): FailureMode

- Determines how a parent object should handle initialization failure in this object. The default is "warn".

  - `"error"`: support/InitializeError!InitializeError is thrown.
  - `"warn"`: Message is logged and support/InitializableBase!InitializeWarningEvent is raised.
  - `"ignore"`: support/InitializableBase!InitializeWarningEvent is raised.

  #### Returns FailureMode

  Inherited from EntityBase.failureMode

- set failureMode(value): void

- #### Parameters

  - value: FailureMode

  #### Returns void

  Inherited from EntityBase.failureMode

### hideOnDisable

- get hideOnDisable(): boolean

- Determines whether the item should be hidden when menus/MenuItem!MenuItem.isEnabled is set to false. The default is false.

  #### Returns boolean

- set hideOnDisable(value): void

- #### Parameters

  - value: boolean

  #### Returns void

### iconId

- get iconId(): string

- The ID of the icon to show for this item, e.g. "gcx-icon-zoom-in".

  #### Returns string

  Implementation of MenuItemState.iconId

- set iconId(value): void

- See menus/MenuItem!MenuItem.iconId.

  #### Parameters

  - value: string

  #### Returns void

  Implementation of MenuItemState.iconId

### id

- get id(): string

- The unique ID for this entity.

  #### Returns string

  Inherited from EntityBase.id

### isDestroyed

- get isDestroyed(): boolean

- See support/InitializableBase!Initializable.isDestroyed.

  #### Returns boolean

  Inherited from EntityBase.isDestroyed

### isEnabled

- get isEnabled(): boolean

- Determines whether the user is able to select this item.

  #### Returns boolean

- set isEnabled(value): void

- #### Parameters

  - value: boolean

  #### Returns void

### isInitialized

- get isInitialized(): boolean

- See support/InitializableBase!Initializable.isInitialized.

  #### Returns boolean

  Inherited from EntityBase.isInitialized

### isToggled

- get isToggled(): boolean

- Determines whether this item is currently toggled from its initial state. This property is only meaningful if menus/MenuItem!MenuItem.canBeToggled is true. When this property is changed, other properties of the menu item will be swapped with those in "alternate". An item can only be toggled if it has an alternate state.

  #### Returns boolean

### itemType

- get itemType(): string

- The item type for this entity when it participates in an App.

  #### Returns string

  Inherited from EntityBase.itemType

### menu

- get menu(): Menu<TMenuItemProps, TMenuProps, this>

- The parent menu that this item belongs to.

  #### Returns Menu<TMenuItemProps, TMenuProps, this>

### root

- get root(): Menu<TMenuItemProps, TMenuProps, this>

- The root menu in the menu hierarchy.

  #### Returns Menu<TMenuItemProps, TMenuProps, this>

### submenu

- get submenu(): Menu<TMenuItemProps, TMenuProps, this>

- A submenu associated with this item.

  #### Returns Menu<TMenuItemProps, TMenuProps, this>

- set submenu(value): void

- #### Parameters

  - value: Menu<TMenuItemProps, TMenuProps, this>

  #### Returns void

### title

- get title(): string

- The human-readable caption for the item.

  #### Returns string

  Implementation of MenuItemState.title

- set title(value): void

- See menus/MenuItem!MenuItem.title.

  #### Parameters

  - value: string

  #### Returns void

  Implementation of MenuItemState.title

##
Methods

### `Protected`_getSerializableProperties

- _getSerializableProperties(): PropertyDefs<TMenuItemProps>

- The property keys and their metadata that are used to implement serializing and deserializing the class instance.

  #### Returns PropertyDefs<TMenuItemProps>

  Overrides EntityBase._getSerializableProperties

### `Protected`_initializableChildCollections

- _initializableChildCollections(): IterableIterator<Collection<InitializableBase<InitializableBaseProperties>>, any, any>

- Collections of child items to initialize. Items that fail to initialize are removed from the collection.

  #### Returns IterableIterator<Collection<InitializableBase<InitializableBaseProperties>>, any, any>

  Inherited from EntityBase._initializableChildCollections

### `Protected`_initializeChildren

- _initializeChildren(): Promise<void>

- Initializes child entities.

  #### Returns Promise<void>

  Inherited from EntityBase._initializeChildren

### `Protected`_onDestroy

- _onDestroy(): Promise<void>

- Called to perform cleanup. Subclasses should override this method rather than destroy() to perform custom cleanup.

  #### Returns Promise<void>

  Inherited from EntityBase._onDestroy

### `Protected`_onInitialize

- _onInitialize(): Promise<void>

- Called to perform initialization of the support/InitializableBase!InitializableBase. Subclasses should override this method rather than initialize() to perform custom initialization.

  #### Returns Promise<void>

  Overrides EntityBase._onInitialize

### `Protected`_postInitialize

- _postInitialize(): Promise<void>

- Called after normal initialization. Note: Child items are initialized before this is called.

  #### Returns Promise<void>

  Inherited from EntityBase._postInitialize

### `Protected`_toPropertyDef

- _toPropertyDef<T>(def): PropertyDef<T>

- Converts the value to a PropertyDef object.

  #### Type Parameters

  - T

  #### Parameters

  - def: PropertyDefSerializeMode | PropertyDefSerializeMode[] | PropertyDef<T>

    The value to convert.

  #### Returns PropertyDef<T>

  Inherited from EntityBase._toPropertyDef

### assignProperties

- assignProperties(properties): void

- #### Parameters

  - properties: Partial<TMenuItemProps>

  #### Returns void

  #### Inherit Doc

  Inherited from EntityBase.assignProperties

### assignPropertiesAsync

- assignPropertiesAsync(properties): Promise<void>

- #### Parameters

  - properties: Partial<TMenuItemProps>

  #### Returns Promise<void>

  #### Inherit Doc

  Inherited from EntityBase.assignPropertiesAsync

### destroy

- destroy(): Promise<void>

- A clean-up function that should get called whenever the item is disposed of.

  #### Returns Promise<void>

  Inherited from EntityBase.destroy

### finishAssignProperties

- finishAssignProperties(): Promise<void>

- #### Returns Promise<void>

  #### Inherit Doc

  Inherited from EntityBase.finishAssignProperties

### getDefault

- getDefault<K>(key): TMenuItemProps[K]

- #### Type Parameters

  - K extends string | number | symbol

  #### Parameters

  - key: K

  #### Returns TMenuItemProps[K]

  #### Inherit Doc

  Inherited from EntityBase.getDefault

### getDefaults

- getDefaults(): TMenuItemProps

- #### Returns TMenuItemProps

  #### Inherit Doc

  Inherited from EntityBase.getDefaults

### getSerializableProperties

- getSerializableProperties(serializeMode?): PropertyDefs<TMenuItemProps>

- Returns the serializable properties.

  #### Parameters

  - `Optional` serializeMode: SerializeMode

    Optional. If specified, only properties that support the given serialization mode will be returned.

  #### Returns PropertyDefs<TMenuItemProps>

  Inherited from EntityBase.getSerializableProperties

### initialize

- initialize(): Promise<void>

- Initializes the item.

  #### Returns Promise<void>

  Inherited from EntityBase.initialize

### toggle

- toggle(): void

- Swaps the current properties for those in "alternate". If there is no alternate state then an error will be thrown.

  #### Returns void

### toItemUri

- toItemUri(): string

- Creates an item:// URI reference to this entity.

  #### Returns string

  Inherited from EntityBase.toItemUri

### toJSON

- toJSON(serializeMode?): TMenuItemProps

- #### Parameters

  - serializeMode: SerializeMode = "all"

  #### Returns TMenuItemProps

  #### Inherit Doc

  Inherited from EntityBase.toJSON

### `Static` create

- create<TMenuItemProps>(properties): MenuItem<MenuItemProperties, MenuProperties>

- Creates the appropriate subclass of menus/MenuItem!MenuItem based on the supplied properties. Applications can customize the default creation behavior by supplying a custom factory object (see menus/MenuItem!MenuItem.factory).

  #### Type Parameters

  - TMenuItemProps extends MenuItemProperties = MenuItemProperties

  #### Parameters

  - properties: TMenuItemProps

    The menu item properties.

  #### Returns MenuItem<MenuItemProperties, MenuProperties>