Clear GRID Serializer Values in hidden field
-
22-01-2021 - |
Question
I have a working Grid Serializer. Now I want to clear the Grid Serializer values without refreshing page. So, I added a jquery script to clear the hidden field:
$("input[name='links[products]']").prop("value", "");
It works fine when I am on the first page, but when I go to the next page and clear the hidden Grid Serializer it will not clear for the previous page.
I can able to see that the Grid Serializer hidden field was empty, but when I tried to do a search or reset filter the hidden values are posted in the form data.
I don't know how the post values are posted even the hidden field was empty. Is there any way to clear the Grid Serializer values?
Solution
<block class="Magento\Backend\Block\Widget\Grid\Serializer\Serializer" name="grid_serializer">
<arguments>
<argument name="input_names" xsi:type="array">
<item name="0" xsi:type="string">products</item>
<item name="1" xsi:type="string">base_price[]</item>
<item name="2" xsi:type="string">final_price[]</item>
</argument>
<argument name="grid_block" xsi:type="string">customer.product.listing</argument>
<argument name="callback" xsi:type="string">getSelected</argument>
<argument name="input_element_name" xsi:type="string">links[products]</argument>
<argument name="reload_param_name" xsi:type="string">products</argument>
</arguments>
</block>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange