Important

You are browsing the documentation for version 4.1 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.

See our Release Process documentation for more information on the currently supported and upcoming releases.

Mass Action Extension

The simplest mass action that works out-of-box with datagrids is delete. To enable it, add the following into the datagrids.yml of the corresponding grid :

 1 datagrids:
 2     users-grid:
 3     ...
 4     actions:
 5         delete:
 6             type:          delete
 7             label:         oro.grid.action.delete
 8             link:          delete_link
 9             icon:          trash-o
10             acl_resource:  oro_user_user_delete

Empty checkboxes and the trash icon will then be displayed in every grid row. By clicking it, you can delete a single current row. A button with label is displayed on right side of the grid header. By click on it, the Delete mass action button appears. Check every necessary row manually or use the checkbox in the header and click Delete to perform the mass action.

If you wish to disable a mass action, specify the following:

1 datagrids:
2     users-grid:
3         ...
4         options:
5             mass_actions:
6                 delete:
7                     enabled: false

In case of more complicated mass types, register your service with the oro_datagrid.extension.mass_action.type tag:

1  oro_customer.datagrid.extension.mass_action.handler.custom:
2      class: Oro\Bundle\CustomerBundle\Datagrid\Extension\MassAction\CustomActionHandler
3      ...
4  tags:
5      - { name: oro_datagrid.extension.mass_action.type, type: disableusers }

Then add the following configuration to the actions.yml file.

 1 operations:
 2 ...
 3     user_disable:
 4         label: oro.user.action.disable.label
 5         acl_resource: oro_user_user_update
 6         entities:
 7             - Oro\Bundle\UserBundle\Entity\User
 8         routes:
 9             - oro_user_view
10             - oro_user_index
11         datagrids:
12             - users-grid
13         datagrid_options:
14             mass_action:
15                 type: disableusers
16                 label: oro.customer.mass_actions.disable_customers.label
17                 handler: oro_customer.datagrid.mass_action.customers_enable_switch.handler.disable
18                 route: oro_datagrid_front_mass_action
19                 route_parameters: []
20                 icon: ban
21                 data_identifier: customerUser.id
22                 object_identifier: customerUser
23                 defaultMessages:
24                     confirm_title: oro.customer.mass_actions.disable_customers.confirm_title
25                     confirm_content: oro.customer.mass_actions.disable_customers.confirm_content
26                     confirm_ok: oro.customer.mass_actions.disable_customers.confirm_ok
27                 allowedRequestTypes: [POST, DELETE]
28                 requestType: [POST]

Note

  • allowedRequestTypes is intended to use for the mass action request server-side validation. If it is not specified, the request is compared to the GET method.

  • requestType is intended to be used for mass action to override the default HTTP request type GET to one from the allowed types. If it is not specified, the GET type is used.

See Operations on how to configure operations described.