2

I want to add product grid in Magento 2 admin customer section with a separate tab, that I got completed, but when I select the checkbox values from grid and hit save.

It does not get the values of that grid and checkbox values in get and post action.

I have checked multiple time and tried lot with that but it seems like not working.

Any help on this will be appreciated and a knowledge sharing parts for others.

Thanks.

2 Answers 2

3

First put block like below code,

view/adminhtml/layout/Custom.xml

<block class="Company\Module\Block\Adminhtml\Product\Edit\Tab\Custom" name="edit.tab.custom"/>
        <block class="Magento\Backend\Block\Widget\Grid\Serializer" name="custom_grid_serializer">
            <arguments>
                <argument name="grid_block" xsi:type="string">edit.tab.custom</argument>
                <argument name="callback" xsi:type="string">getSelectedProducts</argument>
                <argument name="input_element_name" xsi:type="string">product_ids</argument>
                <argument name="reload_param_name" xsi:type="string">products_listing</argument>
            </arguments>
        </block>

<block class="Magento\Framework\View\Element\Template" name="grid_scriptjs" template="Company_Module::scriptjs.phtml"/>

Add template like below code,

In view/adminhtml/templates/scriptjs.phtml

<script>
    require([
        "jquery",

    ], function($){     
        $("input[name='product_ids']").attr('data-form-part','customer_form');      
    });
</script>
0
0

Here is the module that will add new tab in admin customer and also save selected products to database.

Add product grid in customer admin section

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.