Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

point for thousands and comma for decimal #137

Open
pfloriginale opened this issue Dec 31, 2017 · 1 comment
Open

point for thousands and comma for decimal #137

pfloriginale opened this issue Dec 31, 2017 · 1 comment

Comments

@pfloriginale
Copy link

In Italy we have number like this

11.234,99

there's a way?
good job!

@Mottie
Copy link
Collaborator

Mottie commented Apr 24, 2018

Hi @pfloriginale!

You'd need to add a custom parser - demo

$.tablesorter.addParser({
  id: 'number',
  is: function() {
    return false;
  },
  format: function(s) {
    var str = $.trim(s.replace(/[\s.]/g, '').replace(/,/g, '.'));
    var num = parseFloat(str);
    return isNaN(num) ? s : num;
  },
  type: 'numeric'
});

$('table').tablesorter({
  headers: {
    0: {sorter: 'number'}
  }
});

If you're using my fork of tablesorter, then you'd need to set usNumberFormat to false (demo)

$(function() {
  $('table').tablesorter({
		theme: 'blue',
    usNumberFormat: false
  });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants