I am displaying a table of about 3500 rows with DataTables 1.9.0; this naturally looks like a good case for bDeferRender, as the rendering of the table was taking ~20 - 25 seconds. I made that conversion on Friday, and the table comes up much, much quicker (just a second or two). However, some functionality in my application is now broken.
In displaying a filtered subset of the table (say, 2 pages), I invoke a javascript function that I wrote to change the state of some of the cells in the table (one column is a table of checkboxes, so I created a "select all" capability) which is invoked via 'onchange'. The function basically does
where 'selector' is the jQuery selector (in my case, something like '#store_1').
My issue is that when the table spans more than one page, and I haven't visited any pages except the first, I get an error on the jquery selector "oTable.$(selector)"; the error message returned is "a is null". Using Firebug, and placing a breakpoint on that line, I can fire a standard jquery selector ($('#store_1')) and it works just fine; only when I go through the table (oTable.$('#store_1')) does it fail.
In stepping through what is happening in the table selector, it looks like the deferred rendering is preventing the data structures necessary for the jquery selector to work. I've traced this to the following code:
where it bombs out on the jqA.filter(sSelector) line (line 4832 of jquery.datatables.js).
You can see this same error on the example for bDeferRender (http://datatables.net/release-datatables/examples/ajax/defer_render.html) by placing a breakpoint on the line that creates the datatable, and then stepping one line beyond it (so the table will render on the page, and you'll have access to the oTable variable in the watchpoints panel). When you hit the break, step over just enough that the oTable variable is set and the table has rendered. Set a watch on "oTable.$('.sorting_1')" to find all cells that have the sorting class turned on and you'll get the same "a is null" error, which I think is caused by the search progressing to a page other than page 1.
Help? For most of these, I could use a standard jQuery selector (not going through the table); it's inconvenient for some, though, because I'd like to find just the filtered members.
Help?
Thanks!
john
In displaying a filtered subset of the table (say, 2 pages), I invoke a javascript function that I wrote to change the state of some of the cells in the table (one column is a table of checkboxes, so I created a "select all" capability) which is invoked via 'onchange'. The function basically does
var box = oTable.$(selector); var state = box.attr("checked") == "checked"; ...
where 'selector' is the jQuery selector (in my case, something like '#store_1').
My issue is that when the table spans more than one page, and I haven't visited any pages except the first, I get an error on the jquery selector "oTable.$(selector)"; the error message returned is "a is null". Using Firebug, and placing a breakpoint on that line, I can fire a standard jquery selector ($('#store_1')) and it works just fine; only when I go through the table (oTable.$('#store_1')) does it fail.
In stepping through what is happening in the table selector, it looks like the deferred rendering is preventing the data structures necessary for the jquery selector to work. I've traced this to the following code:
/* We need to filter on the TR elements and also 'find' in their descendants * to make the selector act like it would in a full table - so we need * to build both results and then combine them together */ var jqA = $(a); var jqTRs = jqA.filter( sSelector );
where it bombs out on the jqA.filter(sSelector) line (line 4832 of jquery.datatables.js).
You can see this same error on the example for bDeferRender (http://datatables.net/release-datatables/examples/ajax/defer_render.html) by placing a breakpoint on the line that creates the datatable, and then stepping one line beyond it (so the table will render on the page, and you'll have access to the oTable variable in the watchpoints panel). When you hit the break, step over just enough that the oTable variable is set and the table has rendered. Set a watch on "oTable.$('.sorting_1')" to find all cells that have the sorting class turned on and you'll get the same "a is null" error, which I think is caused by the search progressing to a page other than page 1.
Help? For most of these, I could use a standard jQuery selector (not going through the table); it's inconvenient for some, though, because I'd like to find just the filtered members.
Help?
Thanks!
john