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.

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

  • 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 '17 at 9:54
  • create a custom js and manage click event of that button – Nidhi Jul 31 '17 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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