Can I use DataTables only to show filtered stats, without updating the table?
Can I use DataTables only to show filtered stats, without updating the table?
veryaca
Posts: 11Questions: 4Answers: 0
Let me explain what I"m trying to achieve.
I have this large table, and I would like to have a section on the same page where I can see some stats related to this table, without actually filtering it.
So say I have 4,000 lines. I would like to have a list that says how many lines have Monday, how many have Tuesday, etc... without actually applying the filter to the table?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You can use
filter()
for this. The docs have an example. You can check the length of the resulting data to display the count. Its funny, I just answered another question (different need) with an example that you might find useful.See the example I posted in this thread.
Kevin
I don't want the table to update. I just want to be able to grab stats from the table once it's loaded.
So say I have 4,000 rows. Once the DataTable has loaded, I want to show in a list somewhere on the same page, that 1,800 rows have the value Monday (for instance) in a specific column (without filtering the table).
The
filter()
API does not update the table. It returns a data set that can be used in Javascript. Per the docs:Take a closer look at my example and the example in the docs.
Kevin
Also after filtering you can use
count()
to get the number of items returned. Just replacetoArray()
from my example withcount()
.EDIT: I updated my example for you:
http://live.datatables.net/nalotira/2/edit
Kevin
I was about to ask, haha! So say I have this code.
I'm not sure how I would include the
count()
to this? I want to know how much rows have the value 'NBA' in column 1.We probably cross posted. My last post has an example.
Kevin
Thank you so much for your help!