fnGetNodes() only returning visible nodes??

fnGetNodes() only returning visible nodes??

jayalfredprufrockjayalfredprufrock Posts: 5Questions: 0Answers: 0
edited November 2011 in Bug reports
Hopefully I'm not just understanding/using things wrong, but I was under the impression that fnGetNodes() should return all dataTable rows, regardless of whether they are currently visible. It seems that with the latest version, the function is only returning the visible rows. Also, I am loading the data manually at initialization with aaData.

On a related note, I'm trying to retrieve a list of all datatable rows within the "fnInitComplete()" callback and am wondering if the settings object that is passed to the callback can be used reliably to retrieve a list of row nodes, instead of using fnGetNodes() on the object that is returned from a dataTable initialization.

I'm actually working on an expansive php-codeigniter wrapper for controlling DataTables, which has required digging into some of the advanced features DataTables has to offer. Can't wait to share it with everybody.

Thanks Allan,

Andrew

Replies

  • jayalfredprufrockjayalfredprufrock Posts: 5Questions: 0Answers: 0
    edited November 2011
    So I wouldn't waste any of your time, I've tried reproducing the issue on this page http://www.datatables.net/release-datatables/examples/data_sources/js_array.html
    by messing around in the console, and everything works as expected.

    Furthermore, similar investigation on my own page reveals that after using the dropdown to display all entries, the same fnGetNodes() call returns all nodes as expected, even after switching the dropdown value to something smaller. I've tried turning off bStateSave and clearing my cache, but the problem remains. Since this must be some kind of configuration issue on my end, can you think of anything else that might explain this behavior?

    I created a Js Bin demonstrating my problem:

    http://live.datatables.net/egagaz/2/edit

    You'll see in the console that only the visible nodes are printed out even though there are actually a couple more rows hidden.
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    edited November 2011
    Thanks very much for setting up the example - can get straight to what is causing the issue!

    Basically its because you have "bDeferRender": true. What this variable does is that it tells DataTables only to create the TR elements that are needed for a draw (they are then kept once created in case we need to reuse them). So in this case, DataTables has only needed 10 rows - thus you only have 10 nodes on the first draw. If you modify the code slightly to use fnDrawCallback ( http://live.datatables.net/egagaz/3/edit ) you'll see that on the first page you have 10 nodes, then click the paging to go to page 2, and you'll have 18 nodes.

    So if you want all nodes, don't use deferred rendering :-)

    Allan
  • jayalfredprufrockjayalfredprufrock Posts: 5Questions: 0Answers: 0
    Ahhh. Thanks so much allan. I was hoping there would be a simple explanation. :)
  • kunmiikunmii Posts: 2Questions: 0Answers: 0
    How come over here fnGetNodes() returns all the rows in the table, I want only the filtered rows.... #urgent.
  • kunmiikunmii Posts: 2Questions: 0Answers: 0
    http://www.datatables.net/forums/discussion/214/how-to-get-searched-or-filtered-data/p1
    ....found d solution in there...
This discussion has been closed.