Counting numbers of things in a column...

Counting numbers of things in a column...

nickschurchnickschurch Posts: 18Questions: 0Answers: 0
edited February 2012 in General
Hi All,

I'm not quite sure how to go about counting things in a datatables column.

The situation is that I have a tabel with say 35k rows in it that has filters which filter it down to 3k rows. bInfo does a great job at displaying this, but I'd like to display two other bits of information. I'd like to display the number of filtered rows with a value in column 1 that match a string pattern, say [code]/_at/[/code] and, the number of unique values found in the set of values that don't match this pattern.

I'm at a bit of a loss where I could put this counting... as part of the custom filtering function I'm pushing to $.fn.dataTableExt.afnFiltering ?

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    There isn't a built in way to get that information, since, obviously it will depend on your external filters, so you would need to use the fnInfoCallback to manipulate the table information element as you require.

    Allan
  • nickschurchnickschurch Posts: 18Questions: 0Answers: 0
    Hmmm. How can I access the filtered data? fnGetNodes just gets the rows that are actually being draws, while fnGetData get the data for the whole table without filtering. it seems like there should be something like fnGetFilteredData or something that I'm missing...
  • nickschurchnickschurch Posts: 18Questions: 0Answers: 0
    ahhh, nevermind, I found fnGetDisplayNodes() and friends in the plugins...
  • nickschurchnickschurch Posts: 18Questions: 0Answers: 0
    OK, great, so I have my counting function. Now, I'd like to include this information with the other info using fnInfoCallback, but I'm having a problem that this is being called before the table is populate with data (I'm using ajax) and this is throwing an error. If there a way to tell these kinds of functions to wait until the table is populated before executing?
  • nickschurchnickschurch Posts: 18Questions: 0Answers: 0
    I got round the call before population issue with a try/catch that passes gracefully.
This discussion has been closed.