What would be the best way to reset filter fields in GridView? It should fill in all inputs with empty values and show all rows.
On desktop (Delphi and . NET) Grid there is an option to display a footer with all filtering options applied and you can just click on the checkbox to remove all of them.
Apply, Clear, Reset and Cancel ButtonsThe Clear button clears just the filter UI, whereas the Reset button clears the filter UI and removes any active filters for that column. The Cancel button will discard any changes that have been made in the UI, restoring the state of the filter to match the applied model.
Built-in Html
helper provides resetButton()
method to do that which generates the code like that:
<button type="reset"></button>
But this will only work inside the form, for example take a look at _search
view generated in CRUD templates by gii.
For GridView I recommend using another solution: just create link to the same page but without filter parameters.
Example:
echo Html::a('Reset', ['index']);
Official documentation:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With