Counting number of entries on datatable
Counting number of entries on datatable
Hi all,
I got to this thread:
http://datatables.net/forums/discussion/2278/how-to-get-number-of-rows
The problem is that the javascript stops when I run the answers pointed in that thread ( oTable.fnSettings().fnRecordsTotal() and oTable.fnGetData().length ).
I made an example using a previous made one, where I added a button that works when I comment the function meant to count the number of entries, but as soon as I uncomment it, the value doesn't get anything:
http://live.datatables.net/niwajato/41/edit
I think it might be because the thread is 5 years old, and up to now those methods have been deprecated and a new method(s) have been implemented.
Any help would be very appreciated.
José Gonçalves
Replies
Got an alternative working:
using pageInfo, I can get the attribute recordsTotal to tell me how many records the table has.
Code:
Working example here: http://live.datatables.net/niwajato/42/edit
Yes,
page.info()
will tell you ordata()
(table.data().length()
for example).Allan
Hi Allan,
Thanks for your reply.
I think I'll use oTable.data().length instead, since it spends one less resource than the method I've found :)