Forums › Forums › OroPlatform › OroPlatform – Programming Questions › Custom mass actions
This topic contains 7 replies, has 2 voices, and was last updated by Yevhen Shyshkin 9 years, 3 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- December 17, 2014 at 2:36 am #33646
Hello,
I need of create a custom mass action on my datagrid.
On DataGridBundle/Resources/doc/backend/extensions/mass_action.md
I read “**@TODO create doc**” :(
There is some bundle that I can see for a simple example?
Thanks! - CreatorTopic
- AuthorReplies
- December 17, 2014 at 3:17 am #33647
Hello, infocurci.
Sorry for inconvenience with the doc, we’ll update it ASAP.
You can look at delete mass action and it’s usage in contacts grid.
December 20, 2014 at 7:03 am #33648Hello,
thanks for your reply.
I read the example and I created my mass action action on datagrid, that calls a function on controller. It works fine but the application fails on return response, I don’t know what type of response the function must return.
If I return an array json:12345678$data = ['successful' => true,'message' => 'Success!!!',];return new JsonResponse($data);it load an empty page.
I need to reload same page, with datagrids (I have 2 datagrid) updated… or better, reload only datagrids.December 22, 2014 at 3:16 am #33649Look’s like response is correct. Please, check for JS errors and try to debug Oro/Bundle/DataGridBundle/Resources/public/js/datagrid/action/mass-action.js (this file handles mass action processing on JS) – probably, it’s either didn’t initialized correctly, or there is an error in processing.
I assume that you are using ajax mass action – so, you can debug delete mass action on contacts grid and compare with your processing.
Also you can check whether custom controller action is really required in your case – if no then you can create only handler and use default mass action controler action.
December 22, 2014 at 9:45 am #33650Hello,
the script, now, works fine.
The mass action, after return “Success” reply, print a message on top of page and reload the datagrid. So far, so good!
My page is made of 2 datagrids, and I need reload also the other grid.
It’s possible?
If not, is possible reload entire page after datagrid return reply?December 22, 2014 at 10:09 am #336511) You have to create custom JS mass action and refresh your second grid in this method.
2) You can use redirect action insted of ajax actions and redirect to the same page.
IMHO, first solution is more clear and better.
December 22, 2014 at 1:46 pm #33652Hello,
I extended the action with my custom action and it works (if, on event “_onAjaxSuccess”, I add a javascript fake message with alert() function, it appears).
Anyway, I don’t know how refresh another datagrid from this function..December 23, 2014 at 3:17 am #33653To refresh a grid you have to inject mediator module via requirejs (oroui/js/mediator) and trigger event
"datagrid:doRefresh:<gridName>"
. Here is example for customer orders grid:mediator.trigger("datagrid:doRefresh:magento-customer-orders-widget-grid");
Also you can look at this example – it does exactly what you need.
- AuthorReplies
The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.