DropDownButton
23 Sep 20256 minutes to read
DropDownButton component is used to toggle contextual overlays for displaying list of action items.
It can contain both text and images.
<button id="element">DropDownButton</button><script>
var dropDownButtonObj = new DropDownButton({items: [{ text: 'Action1' }, { text: 'Action2' },{ text: 'Action3' }]);
dropDownButtonObj.appendTo("#element");
</script>Properties
animationSettings DropDownMenuAnimationSettingsModel
Specifies the animation settings for opening the sub menu in the DropDownMenu.
The settings control the duration, easing, and effect of the animation applied when the sub menu opens.
Defaults to { effect: ‘None’ }
closeActionEvents string
Specifies the event to close the DropDownButton popup.
Defaults to ””
content string
Defines the content of the DropDownButton element that can either be a text or HTML elements.
Defaults to ””
createPopupOnClick boolean
Specifies the popup element creation on open.
Defaults to false
cssClass string
Defines class/multiple classes separated by a space in the DropDownButton element. The
DropDownButton size and styles can be customized by using this.
Defaults to ””
disabled boolean
Specifies a value that indicates whether the DropDownButton is disabled or not.
Defaults to false.
enableHtmlSanitizer boolean
Specifies whether to enable the rendering of untrusted HTML values in the DropDownButton component.
If ‘enableHtmlSanitizer’ set to true, the component will sanitize any suspected untrusted strings and scripts before rendering them.
Defaults to true
enablePersistence boolean
Enable or disable persisting component’s state between page reloads.
Defaults to false
enableRtl boolean
Enable or disable rendering component in right to left direction.
Defaults to false
iconCss string
Defines class/multiple classes separated by a space for the DropDownButton that is used to
include an icon. DropDownButton can also include font icon and sprite image.
Defaults to ””
iconPosition SplitButtonIconPosition
Positions the icon before/top of the text content in the DropDownButton. The possible values are:
- Left: The icon will be positioned to the left of the text content.
- Top: The icon will be positioned to the top of the text content.
Defaults to “Left”
itemTemplate string|Function
Specifies the template content to be displayed.
Defaults to null
items ItemModel[]
Specifies action items with its properties which will be rendered as DropDownButton popup.
Defaults to []
locale string
Overrides the global culture and localization value for this component. Default global culture is ‘en-US’.
Defaults to ’’
popupWidth string|number
This property defines the width of the dropdown popup for the DropDownButton component.
Defaults to “auto”
target string|Element
Allows to specify the DropDownButton popup item element.
Defaults to ””
Methods
addEventListener
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
addItems
Adds a new item to the menu. By default, new item appends to the list as the last item,
but you can insert based on the text parameter.
| Parameter | Type | Description |
|---|---|---|
| items | ItemModel[] |
Specifies an array of JSON data. |
| text (optional) | string |
Specifies the text to insert the newly added item in the menu. |
Returns void
appendTo
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
attachUnloadEvent
Adding unload event to persist data when enable persistence true
Returns void
dataBind
When invoked, applies the pending property changes immediately to the component.
Returns void
destroy
Destroys the widget.
Returns void
detachUnloadEvent
Removing unload event to persist data when enable persistence true
Returns void
focusIn
Sets the focus to DropDownButton
its native method
Returns void
getLocalData
Returns the persistence data for component
Returns any
getPersistData
Get the properties to be maintained in the persisted state.
Returns string
getRootElement
Returns the route element of the component
Returns HTMLElement
handleUnload
Handling unload event to persist data when enable persistence true
Returns void
refresh
Applies all the pending property changes and render the component again.
Returns void
removeEventListener
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
removeItems
Removes the items from the menu.
| Parameter | Type | Description |
|---|---|---|
| items | string[] |
Specifies an array of string to remove the items. |
| isUniqueId (optional) | boolean |
Set true if specified items is a collection of unique id. |
Returns void
toggle
To open/close DropDownButton popup based on current state of the DropDownButton.
Returns void
Inject
Dynamically injects the required modules to the component.
| Parameter | Type | Description |
|---|---|---|
| moduleList | Function[] |
? |
Returns void
Events
beforeClose EmitType<BeforeOpenCloseMenuEventArgs>
Triggers before closing the DropDownButton popup.
beforeItemRender EmitType<MenuEventArgs>
Triggers while rendering each Popup item of DropDownButton.
beforeOpen EmitType<BeforeOpenCloseMenuEventArgs>
Triggers before opening the DropDownButton popup.
close EmitType<OpenCloseMenuEventArgs>
Triggers while closing the DropDownButton popup.
created EmitType<Event>
Triggers once the component rendering is completed.
open EmitType<OpenCloseMenuEventArgs>
Triggers while opening the DropDownButton popup.
select EmitType<MenuEventArgs>
Triggers while selecting action item in DropDownButton popup.