Monday, August 1, 2011

Tablesorter modification to handle checkboxes

Needing to sort tables that contain checkboxes is a relatively common need but despite this I was not able to find a custom developed parser for tablesorter so I rolled my own.

ts.addParser({
  id: 'checkbox',
  is: function(s) { return false; },
  format: function(s, table, cell) { return $(cell).find('input[type*=checkbox]').is(':checked'); }, 
  type: 'numeric'
});

No comments:

Post a Comment