The ContextMenu is a graphical user interface that appears on the user right click/touch hold operation.
<div id = 'target'></div>
<ul id = 'contextmenu'></ul>
<script>
var contextMenuObj = new ContextMenu({items: [{ text: 'Cut' }, { text: 'Copy' },{ text: 'Paste' }], target: '#target'});
</script>
Specifies the animation settings for the sub menu open.
Defaults to { duration: 400, easing: ‘ease’, effect: ‘SlideDown’ }
string
Defines class/multiple classes separated by a space in the Menu wrapper.
Defaults to ”
boolean
Specifies whether to enable the rendering of untrusted HTML values in the Context Menu component. If ‘enableHtmlSanitizer’ set to true, the component will sanitize any suspected untrusted strings and scripts before rendering them.
Defaults to true
boolean
Enable or disable persisting component’s state between page reloads.
Defaults to false
boolean
Enable or disable rendering component in right to left direction.
Defaults to false
boolean
Specifies whether to enable / disable the scrollable option in ContextMenu.
Defaults to false
string
Specifies the filter selector for elements inside the target in that the context menu will be opened.
Defaults to ”
number
If hoverDelay is set by particular number, the menu will open after that period.
Defaults to 0
string
| Function
This property allows you to define custom templates for items in the ContextMenu.
Defaults to null
Specifies menu items with its properties which will be rendered as ContextMenu.
Defaults to []
string
Overrides the global culture and localization value for this component. Default global culture is ‘en-US’.
Defaults to ”
boolean
Specifies whether to show the sub menu or not on click. When set to true, the sub menu will open only on mouse click.
Defaults to false
string
Specifies target element selector in which the ContextMenu should be opened.
Defaults to ”
Adds the handler to the given event listener.
Parameter | Type | Description |
---|---|---|
eventName | string |
A String that specifies the name of the event |
handler | Function |
Specifies the call to run when the event occurs. |
Returns void
Appends the control within the given HTML element
Parameter | Type | Description |
---|---|---|
selector (optional) | string | HTMLElement |
Target element where control needs to be appended |
Returns void
Adding unload event to persist data when enable persistence true
Returns void
Closes the ContextMenu if it is opened.
Returns void
When invoked, applies the pending property changes immediately to the component.
Returns void
Destroys the widget.
Returns void
Removing unload event to persist data when enable persistence true
Returns void
This method is used to enable or disable the menu items in the Menu based on the items and enable argument.
Parameter | Type | Description |
---|---|---|
items | string[] |
Text items that needs to be enabled/disabled. |
enable | boolean |
Set true /false to enable/disable the list items. |
isUniqueId (optional) | boolean |
Set true if it is a unique id. |
Returns void
This method is used to get the index of the menu item in the Menu based on the argument.
Parameter | Type | Description |
---|---|---|
item | MenuItem | string |
item be passed to get the index |
isUniqueId (optional) | boolean |
Set true if it is a unique id. |
Returns number[]
Returns the persistence data for component
Returns any
Returns the route element of the component
Returns HTMLElement
Handling unload event to persist data when enable persistence true
Returns void
This method is used to hide the menu items in the Menu based on the items text.
Parameter | Type | Description |
---|---|---|
items | string[] |
Text items that needs to be hidden. |
isUniqueId (optional) | boolean |
Set true if it is a unique id. |
Returns void
It is used to insert the menu items after the specified menu item text.
Parameter | Type | Description |
---|---|---|
items | MenuItemModel[] |
Items that needs to be inserted. |
text | string |
Text item after that the element to be inserted. |
isUniqueId (optional) | boolean |
Set true if it is a unique id. |
Returns void
It is used to insert the menu items before the specified menu item text.
Parameter | Type | Description |
---|---|---|
items | MenuItemModel[] |
Items that needs to be inserted. |
text | string |
Text item before that the element to be inserted. |
isUniqueId (optional) | boolean |
Set true if it is a unique id. |
Returns void
This method is used to open the ContextMenu in specified position.
Parameter | Type | Description |
---|---|---|
top | number |
To specify ContextMenu vertical positioning. |
left | number |
To specify ContextMenu horizontal positioning. |
target (optional) | HTMLElement |
To calculate z-index for ContextMenu based upon the specified target. |
Returns void
Applies all the pending property changes and render the component again.
Returns void
Removes the handler from the given event listener.
Parameter | Type | Description |
---|---|---|
eventName | string |
A String that specifies the name of the event to remove |
handler | Function |
Specifies the function to remove |
Returns void
It is used to remove the menu items from the Menu based on the items text.
Parameter | Type | Description |
---|---|---|
items | string[] |
Text items that needs to be removed. |
isUniqueId (optional) | boolean |
Set true if it is a unique id. |
Returns void
This method is used to set the menu item in the Menu based on the argument.
Parameter | Type | Description |
---|---|---|
item | MenuItem |
item need to be updated. |
id (optional) | string |
id / text to be passed to update the item. |
isUniqueId (optional) | boolean |
Set true if it is a unique id. |
Returns void
This method is used to show the menu items in the Menu based on the items text.
Parameter | Type | Description |
---|---|---|
items | string[] |
Text items that needs to be shown. |
isUniqueId (optional) | boolean |
Set true if it is a unique id. |
Returns void
Dynamically injects the required modules to the component.
Parameter | Type | Description |
---|---|---|
moduleList | Function[] |
? |
Returns void
EmitType<BeforeOpenCloseMenuEventArgs>
Triggers before closing the menu.
Triggers while rendering each menu item.
EmitType<BeforeOpenCloseMenuEventArgs>
Triggers before opening the menu item.
Triggers once the component rendering is completed.
EmitType<OpenCloseMenuEventArgs>
Triggers while closing the menu.
EmitType<OpenCloseMenuEventArgs>
Triggers while opening the menu item.
Triggers while selecting menu item.