I am using the jQuery tablesorter plugin. I know how to disable sorting on a column by using the jQuery Metadata plugin:
<th class="{sorter: false}">Don't sort me</th>
But I would rather do this by setting a class, so I don't have to use an additional plugin. Also I think I would remember the class name easier than remembering this JSON syntax. How can I do the same same thing using this syntax:
<th class="not-sortable">Don't sort me</th>
I think the only way to get this to work is modifying the source code of the plugin.
At jquery.tablesorter.js
, Line 483:
function checkHeaderMetadata(cell) {
if (($.metadata) && ($(cell).metadata().sorter === false)) {
return true;
};
return false;
}
Change this code to:
function checkHeaderMetadata(cell) {
if ((($.metadata) && ($(cell).metadata().sorter === false)) || $(cell).hasClass("not-sortable")) {
return true;
};
return false;
}
Now the function checkHeaderMetadata
is also returning true, if the cell has a class named not-sortable
.