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>