我有一个jquery数据表。在排序我需要保持特定行冻结。
HTML:
<table id="testTable">
<thead>
<td>col1</td>
<td>col2</td>
</thead>
</table>
JS:
var table;
(function () {
var firstData = "<tr class='special'>" +
"<td>" +
"cellSpecial1" +
"</td>" +
"<td>" +
"cellSpecial2" +
"</td>" +
"</tr>" +
"<tr>" +
"<td>" +
"cell11" +
"</td>" +
"<td>" +
"cell12" +
"</td>" +
"</tr>" +
"<tr>" +
"<td>" +
"cell21" +
"</td>" +
"<td>" +
"cell22" +
"</td>" +
"</tr>";
debugger;
$(firstData).appendTo($('#testTable'));
table = $('#testTable').DataTable({
aoRowDefs: [{
bSortable: false,
aTargets: ['special']
}]
});
//new $.fn.dataTable.FixedHeader( table );
})();
答案 0 :(得分:0)
我认为您可以使用此代码循环遍历行,并省略所需的行 -
$('#testTable').children().each(function(i,e) {
if( $(e).children().first().text() == 'Special' ) {
} else {
//sort the other rows
}
});