OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions Custom mass actions with WindowMassAction

This topic contains 8 replies, has 3 voices, and was last updated by  golriz.nourani 7 years, 11 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #34067

    fdellutri
    Participant

    Hi all,
    I’m developing a custom mass action that, before to be performed on selected records, it must show a dialog window to user with a custom form that I defined as a Type. As the user compiles the form and submits it, the mass action can be performed on selected records. In my case, the mass action consists in the creation of a batch job.

    My question is about which is the best method to follow between:
    1) to perform the logic of the mass action directly in the controller of the window dialog, by receiving the post with the form’s data and by creating the job. In this case I need a way to get in the dialog controller the records that the user has selected in the datagrid: in case the user have selected “all”, i need the querybuilder coming from the datagrid.

    2) to receive data in the dialog controller as in the case (1), but passing the data to a specific handler implementing the MassActionHandlerInterface, like it happens in the AjaxMassAction. I see that in this case I’m able to give the querybuilder, but I don’t know how to invoke that handler from the submit button of the dialog and pass form’s data to it.

    Any help will be appreciated!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Author
    Replies
  • #34068

    fdellutri
    Participant

    any suggestion?

    #34069

    Yevhen Shyshkin
    Participant

    Hello, fdellutri.

    It should be rather second option. Here is what I think.

    You can use WidgetMassAction (that was created to handle action with any widget) to handle dialog. This dialog will have it’s own controller to render form, but result should be sent to GridController::massActionAction (like regular delete action) – just don’t forget to include original mass action options (inset, values, filters). Then you should create your own handler (implementation of MassActionHandlerInterface), specify it as a service and pass service ID to mass action. During the action execution your handler will be triggered, and it will receive all request data (including your form data) via $data argument. The final thing you need to do is to handle json response at your dialog.

    I hope it will help you. Feel free to post here any questions related to this issue.

    #34070

    Yevhen Shyshkin
    Participant

    Also, if you need some additional form processing logic – you can submit form to your own controller, process it there and then call mass action dispatcher.

    #34071

    fdellutri
    Participant

    Thank you Yevhen, it works!

    #34072

    golriz.nourani
    Participant

    Hello
    is it possible explain how should I set original mass action options , and how could I define dialog of mass action?
    is there any example?
    thanks

    #34073

    Yevhen Shyshkin
    Participant

    Hello.

    Mass action options can be defined in mass action itself and in grid configuration, later they will be merged (datagrid options should have higher priority).

    As for dialog – you should use WidgetMassAction as a basic action and create appropriate JS action (defined in “frontend_type” option). Unfortunately, we don’t have any examples of dialog mass action out of the box, but you can use regular dialog action as an example – technically mass actions are regular grid actions, so interfaces are quite the same.

    #34074

    golriz.nourani
    Participant

    Thanks for your explanation ,
    I am working on it.

    #34075

    golriz.nourani
    Participant
Viewing 8 replies - 1 through 8 (of 8 total)

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top