MassActions component
Overview
The MassActions component allows performing actions with multiple selected items. Must be a child of the Listing component.
See the Admin Design Pattern Library (MassActions) topic for information about the UI design patterns that can be implemented using the MassActions component.
Component Elements (classes, files)
The following are the component elements:
- Constructor
app\code\Magento\Ui\view\base\web\js\grid\massactions.js
- Template:
app\code\Magento\Ui\view\base\web\templates\grid\actions.html
Dependencies on Other Components
Dependency on the following components:
- Collapsible:
app\code\Magento\Ui\view\base\web\js\lib\collapsible.js
- Modal window with confirmation:
app\code\Magento\Ui\view\base\web\js\modal\confirm.js
- Modal window with alert:
app\code\Magento\Ui\view\base\web\js\modal\alert.js
MassActions configuration
Extends Collapsible
configuration with the following options:
Option | Description | Type | Default Value |
---|---|---|---|
actions |
A list of available actions. | MassAction[] |
- |
noItemsMsg |
Message displayed when a user attempts to perform an action without any selected items. | String | 'You haven't selected any items!' |
stickyTmpl |
Additional component's template that is used when its parent Toolbar component receives a fixed position. | String | ui/grid/sticky/actions |
template |
Path to the component’s .html template. |
String | ui/grid/paging/sizes |
MassAction interface
Option | Description | Type | Required |
---|---|---|---|
callback |
ColumnAction | Optional | |
confirm |
Confirmation message displayed before applying the action. | { title: string; message: string; } |
Optional |
label |
Action's label displayed in the list of actions. | String | Required |
type |
Action's identifier. | String | Required |
url |
Path to the controller responsible for action handling. | String | Optional |
Methods and Events
The following API methods are available:
getAction
- returns the action instance found by the provided identifieraddAction
- adds a new action to the actionsapplyAction
- applies the specified action as identifier actiongetSelections
- returns the object with current selections
Example configuration modifications:
Redefining the link to the template
Specifying action with confirmation
Action with a custom callback
Callback is provided by another component.
Instance replacement: one instance of a component
Redefine link to constructor.