jQuery selector incompatibile with deferRender

jQuery selector incompatibile with deferRender

remyjetteremyjette Posts: 7Questions: 1Answers: 0

Example:
http://live.datatables.net/yupeqan/1/edit

If you use deferRender and then pass a string to the rows() function, you will get the following error in the console:

Uncaught TypeError: Cannot read property 'nodeType' of null

Looking through it with a debugger, this is because the elements array passed to jQuery.grep has length equal to the total number of items in the table, not just the rendered ones. The rendered ones are their respective nodes, and the rest are undefined which throws an error when accessing elem.nodeType.

Replies

  • AluminumCatAluminumCat Posts: 23Questions: 0Answers: 0

    Whoa! This is the exact problem i've been crying about for a week. I thought it was just me doing something wrong. I noticed if you pass in a $() object instead of just a string, it does work... but I dunno if it works like it should. It certainly can't access things that havent been rendered yet. And Im not sure if it's supposed to behave that way or not.

    so try putting in $('.first') instead of '.first' and see what happens.

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Yes, I need to get this sorted. Thanks for flagging it up and the test case. I'll post back here when I've committed a fix.

    Allan

  • davidcfkdavidcfk Posts: 3Questions: 1Answers: 0

    Ahhh I bumped into this problem as well. Turned on deferRender, even basic returning which rows were selected results in that very error.

    I was just trying to do this with deferRender turned on:
    var oTable = $("#myTable").DataTable();
    var rows = oTable.rows(".active").data();

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    I've just committed a proper fix for this (it was a bit of a rabbit warren bug - it just kept going!). I'm rebuilding the nightly with the fix just now and will release 1.10.4 with it later this week. Any testing of the nightly is very welcome!

    Allan

This discussion has been closed.