I have a table which have input
field in the 2 nd column (1st if started with index 0
). It works fine and sort all regular columns except the column which have textboxes. Here's what I've,
Javascript Code
<script src="jQuery-2.1.4.min.js"></script>
<script type="text/javascript" src="jquery.tablesorter.min.js"></script>
<script>
$('#ordertbldata').tablesorter({
headers: {
1: {
sorter: 'textbox_text'
}
}
});
$.tablesorter.addParser({
id: 'textbox_text',
is: function(s) {
console.log('function is called');
return false;
},
format: function(s) {
console.log('function format called');
return $($.trim(s)).val();
},
type: "text"
});
</script>
I've added log
function to debug but the function isn't called. What's wrong I'm doing here ?
UPDATE : Fiddle here
Your demo was declaring the parser after initializing the plugin.
Seems to work well with this configuration
$.tablesorter.addParser({
id: 'textbox_text',
is: function(s) {
return false;
},
format: function(s,table, el) {
return $.trim($(el).find('input').val().toLowerCase());
},
type: "text",
parsed: true,
});