- Small size: ~5kb minified.
- Works on Touch devices.
- Supports IE8+ (not tested with ie7) and all other modern browsers.
- No framework dependency (But registers itself as a jquery plugin if exists.)
bower install rowsorter
<script type="text/javascript" src="/path/dist/RowSorter.js"></script>
handler : drag handler selector (default: null)
tbody : pass true if want to sort only tbody > tr. (default: true)
tableClass : adds this class name to table while rows are sorting (default: "sorting-table")
dragClass : dragging row's class name (default: "sorting-row").
stickTopRows : count of top sticky rows (default: 0),
stickBottomRows : count of bottom sticky rows (default: 0),
onDragStart : (default: null)
onDrop : (default: null)
onDragStart: function(tbody, row, old_index) {
// finding the table
var table = tbody.tagName === "TBODY" ? tbody.parentNode : tbody;
// old_index is zero-based index of row in tbody (or table if tbody not exists)
console.log(table, row, old_index);
}
// if new_index === old_index, this function won't be called.
onDrop: function(tbody, row, new_index, old_index) {
// finding the table
var table = tbody.tagName === "TBODY" ? tbody.parentNode : tbody;
// old_index is stored index of row in table/tbody before start the dragging.
// new_index is index of row in table/tbody after the row has been dragged.
console.log(table, row, new_index, old_index);
}