I've used this table. I need my first row of tbody(which displays average number of the columns) should not be sorted, I mean that row should in top always(below thead) like this:
. How can I do this? I search solution on google and mostly I find put that row on the thead or something like that. But, if I try to put that row on that place, it seems so complex to me. So, is there any way put a class on the row and disabling sortng on that classed row? like: <tr class="average no-sort"></tr>
Add a comment
|
4 Answers
I had the same problem, in my case I solved it this way:
var $tr = $('#yourTable tr.no-sort'); //get the reference of row with the class no-sort
var mySpecialRow = $tr.prop('outerHTML'); //get html code of tr
$tr.remove(); //remove row of table
$('#yourTable').dataTable({
"fnDrawCallback": function(){
//add the row with 'prepend' method: in the first children of TBODY
$('#yourTable tbody').prepend(mySpecialRow);
}
});
Comments
I create the second tbody in my table and just move all rows I need to persist in that another tbody like so:
initComplete: function() {
var self = this;
var api = this.api();
api.rows().eq(0).each(function(index) {
var row = api.row(index);
if (row.data()...) { // condition here
var $row_to_persist = $(row.node());
var $clone = $row_to_persist.clone();
$(self).find('tbody:last').append($clone);
$total_row.remove();
row.remove();
api.draw();
}
});
}