i'm trying to format some data of a table that is constantly updated by ajax
.
I want that the float data become this
1.100.500,00 (currency)
after I sort it.
The problem is that tablesorter
only sorts the float values correctly if they are in the first format. What I need to do is:
- When
ajax
loads the data, show it like (currency), as currency. - When a
table <th>
is clicked to sort data, remove the (currency) currency format and sort the data correctly. - After sorted correctly, re-format the data like (currency), as currency.
I already tried this:( that I've found that it's the solution to many questions here in SO)
$.tablesorter.addParser({
// set a unique id
id: 'thousands',
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s) {
// format your data for normalization
return s.replace('.','').replace(/,/g,'');
},
// set type, either numeric or text
type: 'numeric'
});
$("#table_1").tablesorter({
headers: {
2: {//zero-based column index
sorter:'thousands'
}
}
});
but it's not working.
Any ideas? Thanks.
Aucun commentaire:
Enregistrer un commentaire