getting information about a hidden column
getting information about a hidden column
I've got a dataTable, built from a json file, with a hidden 6th column that I use for filtering by category (a category which doesn't appear in the table)
in my aoColumnDefs it looks like so:
}, {
"aTargets": [5],
"mData": 8,
"bVisible": false
}
I want to query the table somehow to find out how many records of each category are currently shown in the table (there are various other filters that may be applied at any time).
I thought I might be able to use the $ api to get at the column... something like myTable.$('tr td:eq(5)).text()
, but I realize that column doesn't actually appear in the markup.
Is there a built in method that I can get that kind of info out of the table? DataTables obviously has this data because I can filter with it, I just don't know how to get at it. I'm not much of a programmer, so it may be obvious and I'm just overlooking it.
Thanks!
This question has an accepted answers - jump to answer
Answers
Tinkering away, I'm getting close, I think...
This gives me the correct count of a particular Category (term) in the full dataset, but it doesn't reflect the current filtered table dataset.
So how do I get the filtered data?
solved it this way:
if there is a better way (for version 1.9), please let me know.
Otherwise, I hope this answer helps someone else!
Looks like a good way in 1.9. In 1.10 you'd simply use
table.column(5).data().unique().length
:-).Allan
1.10 is looking pretty sweet, Allan - will try to upgrade soon.
One follow on question - does 1.9 store a reference to currently applied filters that I can access?
Not publicly not. It does internally, but there is no public interface for that information in 1.9. 1.10 however, does using
column().search()
.Allan