After a long exhausting search, I have found no answer to my question anywhere. Basically I have dynamically creating a table based on inputs by a user and also inserting a row with only a button after every 4th entry in the table. What I need is for the sorting function to ignore the rows with the button and leave them in place while sorting the rest of the table. Does anyone know if this is even possible?
2 Answers
You don't - what to do is use DataTables fnDrawCallback to insert your fourth row on each draw. DataTables will always empty the <tbody> element on each draw, so this would be required anyway.
1 Comment
user1361962
Thank you so much, only problem now is it puts the entries at the end of the table instead of in the appropriate spots. Code is as follows:
"fnDrawCallback": function (oSettings) { var rows = $('.searchResultRow'); rows.each(function (index) { if (index == 4 || index == 9) { var insertLearn = $("<tr></tr>").addClass("searchResultRow "); insertLearn.append(buildCell().attr('colspan', 9).html("<img src='../img/LearnMoreAnimated_v1-1.gif' />")); $("#results_table > tbody").append(insertLearn); } });"fnDrawCallback": function (oSettings) { }
var rows = $('.searchResultRow');
rows.each(function (index) {
if (index == 4 || index == 9) {
var insertLearn = $("<tr></tr>").addClass("searchResultRow ");
insertLearn.append(buildCell().attr('colspan', 9).html("<img src='../img/LearnMoreAnimated_v1-1.gif' />"));
$("#results_table > tbody > tr").eq(index).after(insertLearn);
}
});
}
was how I was able to get it....thanks for the help in pointing me in the right direction.