DataTables rows.add() is missing rows
DataTables rows.add() is missing rows

When I run the following code with varying amounts of data, only a subset of the rows are added.
In the following example, the createdRow callback is always called the same amount of times as elements in the array of rows (ie. 5 out of 5). However, the rowCallback callback is only called a subset of those times(ie. 3 out of 5). I'll pass 5 rows and 3 will be added or 13 rows and 8 will be added. I can't figure out a pattern to it.
I've upgraded dataTables to the most recent version (1.10.9). I've tried adding the rows one at a time in a loop.
Any ideas? Thanks!
sub_table = $('#data-table-check-off').DataTable({
"dom": 'ft',
"oLanguage": { "sSearch": "", "sSearchPlaceholder": "Search" },
"sScrollY": "250px",
"stateSave": true,
"lengthChange": false,
"paging": false,
"rowCallback": function(row, data, index) {
console.log("In rowCallback");
},
"createdRow": function(row, data, index) {
console.log("in createdRow");
});
var rows = [["12","Lorenzo"],["14", "Holly"],["15", "Chad"],["16", "Bear"],["17", "Zack"]];
sub_table.rows.add(rows).draw(false);
Answers
Can you replicate it in a JSBin?
I literally just copy and pasted your code into one, here, and it worked fine, you were just missing one
}
in your code above, im assuming you just didnt paste it in here though, since it was a fatal errorIn the JSBin instance I created with your code, the JS shows:
So it seems to be working fine..
Update: Upon further testing, I found this only happens on one of my pages. I cannot reproduce it in JSBin.
All pages that access this table are importing the same JS and HTML for the table. Something outside of the datatable must be effecting it somehow since its calling the same code? Not sure what yet... still troubleshooting.
Any ideas for other ways to do this in case I'm encountering some weird bug?
Do you have a filter applied to the table perhaps? That's the best I've got without being able to see it.
Allan
If I can't reproduce it with the exact code you supplied, then that obviously runes out that segment of code, either some other code is interfering with that code, or its some other code all together causing this.
If you cant reproduce it on JSBin, and we cant see the page itself, then theres not much else we can do here, past ruling out the code you previously supplied.
Can you supply all the code for the page you're referring to thats related to the DataTables initiation?