reset filtered table
reset filtered table
54696d20
Posts: 75Questions: 18Answers: 0
Here is my example. Click on filter and select something you want to filter. The table filters out what you want to see. If you hit the reset button. It doesn't do anything. Any ideas
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
It seems to work fine for me!
Just incase this is useful for you, we are currently working on SearchPanes and it is getting very close to an official release. Here are some links to an example, and a link to the feedback post for more info.
Hope this helps,
Sandy
There are a couple issues I see with your code. If I select a grade, click filter, then click reset it works. Thats because the grade filter is using column(4).search(). This won't clear the select2 search plugin.
You need to rearrange your search plugins. Each time
FilterEOCTable
is executed, for example andprogramChecked
contains array values you are pushing a new copy of the plugin onto the search stack. They should only be pushed one and I would do so at the beginning of your script, like this example:http://live.datatables.net/yisaqore/1/edit
Inside the plugin you can check for the length of
programChecked
and simply returntrue
if empty or run through your code as normal.If you want the
programChecked
to be cleared when clicking thereset
button then clear the select2 options and when draw is executed the empty check you move into the plugin will returntrue
for all the rows.As Sandy mentioned the Search Panes plugin might be work checking out.
Kevin
@sandy I'm not seeing that its resetting the table. If I filter out a program (TB for example) I'm looking at 2 rows. If I click on reset. The table isn't showing the original rows.
@kthorngren Yes, if I filter just by the grade, it works. If I filter out by program it filters, but doesn't reset. I haven't put in the logic to reset the select2 select, but the table isn't resetting. Also, I'm not sure what you sent me
Thanks for the help
As Kevin said:
This can be demonstrated by
pop()
ing one off and doing a draw. Kevin's suggestions are the way to go.I guess I'm not understanding. Reset button calls a different method. So I can't just reset and show all the data again in the table?
I didn't change all of your code, just enough to hopefully get you going.
http://live.datatables.net/fihubuzi/1/edit
The first thing that happens is the select2 element is populated. Next the
Program
search plugin is pushed onto the search stack. I moved the code to check for values in the select2 inside the plugin and placed a defaultreturn true
at the end if the select2 is empty.In the
resetFilter
event handler I added the following, note it needs to run before you call draw():So now you can filter on program
TA
, etc then click reset to have it clear those filters. You will need to do the same with yourfailedChecked
plugin. Also note you only need to call draw once for the plugins to run.Kevin
@kthorngren It took you moving that $.fn.dataTable.ext.search.push outside for it to click. I was thinking that it needed to be called each time. Now everyone's comments make since. Thanks again!