0

I am using Magento ver. 2.1.7 CE .

I added new button "Validate" in UI component layout as follows

<item name="buttons" xsi:type="array">          
<item name="print" xsi:type="array">
    <item name="name" xsi:type="string">print</item>
    <item name="label" xsi:type="string" translate="true">Validate</item>
    <item name="sortOrder" xsi:type="number">0</item>
    <item name="class" xsi:type="string">primary</item>
    <item name="url" xsi:type="string">*/*/save</item>
</item>
<item name="add" xsi:type="array">
    <item name="name" xsi:type="string">add</item>
    <item name="label" xsi:type="string" translate="true">Add New</item>
    <item name="class" xsi:type="string">primary</item>
    <item name="url" xsi:type="string">*/*/add</item>
</item></item>

I want to validate the checkbox for limit the selection not more than two items before submission.

If more than two selection, show popup message to user.

Screenshot

Thanks.

2 Answers 2

0

Instead of placing validate button you can validate records in mass action file.I think it is better option because if user forgot to click on validate and direct click on mass action then all selected record operation will be performed

2
  • Thanks for your reply. Ya it not only perform validate, also do some function after validation...I just put sample button to explain. I want do mass selection function using button in above grid
    – Govind
    Jul 31, 2017 at 9:54
  • create a custom js and manage click event of that button
    – Nidhi
    Jul 31, 2017 at 10:39
0

Create a custom js in view->web->js->customname.js

require([
    "jquery",
    "customname"
    ], function($){
    $(document).ready(function() {

            $("#buttonid").click(function()
            {

                $(".admin__form-field-control .admin__control-select").val(this.id);        
                //call ajax here
            });

   });

in js file handle click event and get id of selected row and lastly include this js file in head section of your xml file

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.