Search in rows already hidden by filter
Search in rows already hidden by filter
Hi everyone:
I am using DataTables to show the accounting accounts of my company(I have a total of 9643 records), and I have already filtered out the ones beginning with '704', '705', '811', '950' and others (using search()
). That gives me a total of 3425 hidden rows. Now I want to unhide some of them. I've found out how to get the hidden rows by using rows()
and passing {search:'removed'}
as a parameter. I already unhide them using pure javascript, but it is a bit slow when dealing with 3000+ rows.
So the question is: Is there a way to apply some of the API methods (like search()
) to search between those hidden rows?
Thanks in advance,
Andy
This question has accepted answers - jump to:
Answers
Currently no - there isn't an API to toggle the filtering state of a row, although that is a nice idea and possibly how I could implement filtering in DataTables in future. Certainly for 1.11 it needs an overhaul!
The search applied is currently reapplied on each full draw (that probably won't change) so whatever is searched on by
search()
will be reapplied. Long way of saying, if you want to use the built in search options, you would need to update your call tosearch()
to match your new requirements.Allan
Sorry, looks like I didn't explain myself so well: I can hide and unhide the rows, using a hidden column with the visible indicator and
row().invalidate()
. But I have around 3000+ hidden rows, and iterate over them using pure javascript is slow. I'm just wondering if there is a way to use theDataTables.Api
object returned byrows({search:'removed'})
and iterate over it using some API method. I suppose I have to keep using javascript cycles :D. I appreciate the help, Allan, looking forward 1.11. Kudos!Oh I see - that's a nice way of doing it :-)
You could use
rows().every()
to loop over the removed rows:Allan
Yep, that's what I'm already doing, the only problem is when there are thousands of hidden rows :D. But, it works, so...
Thanks for all the help, keep all the good work up!
The part that slows down the
every
function is that it creates a new API instance for each call - with the data and context appropriately set for the row in question.Indexes would be faster (looping over
rows().indexes()
, but you would still need to use the API to modify the data. It is possible that will be faster since there is less context switching. If you try it, I would be interested to know the result!Allan