DataTables plug-in for displaying sort priorities in each sorted column header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#example').dataTable().fnSortPriorities(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.dataTableExt.oApi.fnSortPriorities = function(oSettings) { | |
var $this = $(this); | |
$this.find('> thead tr th').each(function(i, v) { | |
v.innerHTML += '<div class="dataTable-sort-priority"></div>'; | |
}); | |
function checkSort(sorts) { | |
var $priorities = $this.find('> thead tr th div.dataTable-sort-priority'); | |
$priorities.html(''); | |
if (sorts && sorts.length > 1) { | |
for (var i=0,len=sorts.length; i<len; ++i) | |
$priorities[sorts[i][0]].innerHTML = (i + 1); | |
} | |
} | |
$this.on('sort', function(ev, oSettings) { | |
checkSort(oSettings.aaSorting); | |
}); | |
// Check for initial multisort | |
checkSort(oSettings.aaSorting); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table thead tr th div.dataTable-sort-priority { | |
float: right; | |
font-size: 9px; | |
padding-right: 5px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment