(I’m new w/ Enterprise license). With scripting, how can you clear header filters (#select_filter & #text_filter)? And, how can I script setting/applying a filter?
I’m working on a grid displaying around 2000 product records.
There are 7 “types” of products (say as an example a single db table full of 7 types of clothing. All products would have price and color columns, but shirts won’t be using the “waist_size” column. I have no control over these different product types all being in a single table).
Each product type has about 5 common fields of data (Category, Price, etc).
But, each product type has about 6 unique fields of data.
Because this is over 40 columns of data (with any one product category only have 11 or so columns of the table used) I’m looking at hiding columns based on the product type, or having user buttons or check boxes to control what columns are displayed.
I’m not sure how I want to do this yet. But, say I make a button called “shirts”. I’d like that button to:
Clear all filters (text, select, ext), so any non-shirt columns don’t have filters left applied.
Set the Product type Column to “Shirt” (filtering to only ‘shirt’ products)
Make sure all columns used by “Shirt” products are visible
Hide any columns not used by “Shirt” products.
One thing I have noticed while playing around: If you clear and reload a grid (… grid.clearAll(); grid.loadXML(‘myData’) …), the filter selections previously made will still be there except they won’t be applied.
I really appreciate any help - thank you!
And, how can I script setting/applying a filter?
You can unfilter grid with:
You can clear filter with:
I’m looking at hiding columns based on the product type
You can hide\show columns in grid with mygrid.setColumnHidden() method:
If you clear and reload a grid (… grid.clearAll(); grid.loadXML(‘myData’) …), the filter selections previously made will still be there except they won’t be applied.
This is expected behaviour of the grid. clearAll() method just deletes all rows from grid, loadXML(‘myData’) just addes new rows to grid. If you want re-apply filter after refreshing grid you may use:
Thanks Olga. That helped a lot. I’m still having some problems though, not with “filters” but with Header Filter fields (#select_filter, #text_filter, etc).
With Header Filters in place:
And using this line to reset the grid:
refreshFilters() cleared what was selected only in the #select_filter. The information in the #text_filter headers was not cleared (what was typed in). Also refreshFilters only cleared the contents of the Header #select_filter after a grid refresh. It doesn’t seem to work unless the grid has been refreshed first.
The information in the #text_filter headers was not cleared (what was typed in).
To clear selection in #select_filter or clear #text_filter textbox you should use:
Thanks Olga! Sorry, I asked the same question twice really.
So, I can hide a column and clear the value of its header filter element:
“grid.filterBy(1,”");" or “grid.filterBy(1,”", true);" will clear all filtering on the grid (not just the filtering in place from column 1). And, directly changing the value of the filter element doesn’t trigger re-evaluating the filter for just that column like typing does.
Thank you - much appreciated!
I figured it out a way to do it:
Step #1: Clear the value of the header filter element:
Step #2: Clear all the filtering applied to the grid (This is suppose to (at least with ‘,true’) just clear the grid filtering in place from the one specified field). Without ‘,true’ all grid filtering will be removed, with ‘,true’ nothing will happen at all. For whatever reason this will remove all filtering on the grid:
Step #3: This function will re-apply filtering to the grid based on the value(s) in the remaining field header elements:
Is there a way to clear all of the filters, including the text typed into the filter boxes, short of refreshing the whole web page?
Unfortunately there is no any specific API for reseting all filters.
You just can use the methods from your previous post.