How to reset all filters in Extjs networks?

How do I reset my ExtJS filters in my grids. More specifically, how do I get a headline to honor changes in filtering.

T. This works great:

grid.store.clearFilter(); 

But the rendering of the headers is incorrect. I need to go into all the menu objects and uncheck the boxes.

I'm lost. I am sure this gives me filterItems:

 var filterItems = grid.filters.filters.items; 

And from each of these filtering elements I can go to the following menu items:

 var menuItems = filter.menu.items; 

But what can I get. I am expecting some kind of checkbox object inside the menu items, and then I can uncheck this checkbox and hopefully the rendering of the title changes.

UPDATE:

I now have this code. The grid screen is cleaned. Then I get filterItems from grid.filters.filters.items and iterate over them. Then I call a function for each of the menu items.

  grid.store.clearFilter(); var filterItems = grid.filters.filters.items; for (var i = 0; i<filterItems.length; i++){ var filter = filterItems[i]; filter.menu.items.each(function(checkbox) { if (checkbox.setChecked) checkbox.setChecked(false, true); }); } 

These flags are called, but nothing happens :(

+6
source share
3 answers

Try this code:

 grid.filters.clearFilters(); 

This should take care of both the grid and its underlying storage.

When you do

  grid.store.clearFilter(); 

it can only clear filters in the storage, but the grid view is not updated with this call. Therefore, to process it automatically for both the grid view and the grid storage, simply use

 grid.filters.clearFilters(); 

Hope this helps!

Hooray!

+15
source

Your update will help me, but you will forget the case when you have text input instead of a checkbox.

So this is my addition to your solution:

  grid.filters.clearFilters(); var filterItems = grid.filters.filters.items; for (var i = 0; i<filterItems.length; i++){ var filter = filterItems[i]; filter.menu.items.each(function(element) { if (element.setChecked) { element.setChecked(false, true); } if(typeof element.getValue !== "undefined" && element.getValue() !== "") { element.setValue(""); } }); } 
0
source

When you use grid with gridfilters and inovoke plugin

grid.filters.clearFilters();

resets the applied filters, but does not clear the value in the text box inside the menu.

For plain text text box, you can try this:

grid.getPlugin('gridfilters').activeFilterMenuItem.activeFilter.setValue();

0
source

Source: https://habr.com/ru/post/971874/


All Articles