jquery tablesorter with accounting number format -


I am using jquery tableer and I am trying to sort a column with such values

$ 100,000 $ 38,000 ($ 4,000) $ 2,000

There are negative numbers within the data (when using the default sort feature), this ($ 4,000) Does not recognize it, so I'm trying to create a custom function to handle it.

The solution given below is with me, and it works fine but I am thinking that what is the better solution? I'm new to jquery and just looking for some insights

  $ (document) .ready (function () {$ .tablesorter.addParser ({// A unique ID id is set: 'Currency-column', is: function (s) {/> return is false; therefore this parser has not been automatically recovered;}; Format: function (s) {s = s.replace (/ $ / g, "S = 's .replace (/ \ (/ g," - "); s = s.replace (/ \) / g," "); return $ .tablesorter.formatFloat (s.replace (new RegExp (/ [^ 0-9 .-] / g), "" ({Headers: {3: {Saucer: 'currency-column'}, 4: {sorter: 'currency-column'}, 5: {sorter : 'Currency-column'}, 6: {sort R: 'currency-column'}, 7: {sorter: wrong}, 10: {sorte R: 'currency-column'}}})}};  

Again, What is needed and I am satisfied with the results (and maybe I should leave it there ...), but if there is a better solution then I

/, / G, "");

Then, your work is created:

  format: function (s) {s = s.replace (/ $ / G, ""); S = s.replace (/ \ (/ g, "-"); s = s.replace (/ \) / g, ""); S = s.replace (/, / g, ""); Refund $ .tablesorter.formatFloat (s.replace (new RegExp (/ [^ 0-9 .-] / g), "")); },  

^. << P>


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -