Skip to content

Instantly share code, notes, and snippets.

Created May 16, 2013 20:18
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
DataTables plug-in for displaying sort priorities in each sorted column header
$.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');
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) {
// Check for initial multisort
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