1
我是js中的插件DataTables的新手,我沒有找到我如何選擇特定的數據在列中排序。例如,在我的表格中,我有一個列有「評級」的列。我只想用百分比而不是其他值來分類。插件數據表:選擇列中的數據進行排序
<td>
<span class="rating">100.00%</span>
<span class="voteup">3 <img src='/images/voteup.png' alt='voteup' /></span>
<span class="votedown"> 0 <img src='/images/votedown.png' alt='votedown' /></span>
<br />
<span class="comment">0 comments</span> <br/>
<span class="views">17 views</span>
</td>
我直接從dom(由php生成)加載數據,這裏是我在js中生成的DataTables數據。
var oTable;
$(document).ready(function() {
oTable = $('#BuildList').dataTable({
"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
"iDisplayLength": -1,
"aoColumns": [
{ "bSortable": false},
{ "bSortable": false},
{ "bSortable": false},
{ "asSorting": [ "asc" ] },
{ "asSorting": [ "desc" ] },
]
});
// To sort by default the column 4
oTable.fnSort([[3, 'asc']]);
});