Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset GridView filter

Tags:

php

gridview

yii2

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.

like image 766
user1900685 Avatar asked Mar 16 '15 07:03

user1900685


People also ask

How do I clear my Devextreme filter?

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.

How to Clear filter in ag grid?

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.


1 Answers

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:

  • yii\helpers\Html resetButton()
  • yii\helpers\Html a()
like image 169
arogachev Avatar answered Sep 28 '22 00:09

arogachev