Javascript 表分拣机货币清洗
我花了相当长的时间在tablesorter周围推来推去,以使它能够使用诸如“R$3.400,95”之类的值 不用说,我失败得很惨。我确实尝试添加一个Javascript 表分拣机货币清洗,javascript,jquery,html-table,tablesorter,Javascript,Jquery,Html Table,Tablesorter,我花了相当长的时间在tablesorter周围推来推去,以使它能够使用诸如“R$3.400,95”之类的值 不用说,我失败得很惨。我确实尝试添加一个标题:{2:{sorter:{currency}属性,但它完全停止了工作。 有人知道怎么解决这个问题吗 Javascript: $.tablesorter.addParser({ // set a unique id id: 'thousands', is: function(s) { // return
标题:{2:{sorter:{currency}
属性,但它完全停止了工作。
有人知道怎么解决这个问题吗
Javascript:
$.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'
});
$(function() {
// call the tablesorter plugin
$("#ver_saida").tablesorter({
decimal: ",",
dateFormat: 'uk',
headers:{2:{sorter:'thousands'}}
});
});
其他标头可以正常工作,但最后一个属性使特定标头停止工作
以下是HTML表格:
<table id="ver_saida" class="tablesorter">
<thead>
<tr>
<th class="sorter-shortDate dateFormat-ddmmyyyy tablesorter-header">Data<span>n</span></th>
<th>Descrição<span>n</span></th>
<th>Valor<span>n</span></th>
<th>Situação<span style="margin-left:2em;">n</span></th>
</tr>
</thead>
<tr class="pago">
<td class="datout">17/05/2012</td>
<td class="desout">atraso teste</td>
<td class="valout"> R$45,46</td>
<td class="situacao">pago</td>
<td class="delCel"><button class="deletar" href="financeiro_deletar.php?id=36">Deletar</button></td>
</tr>
<tr class="npago late">
<td class="datout">13/06/2012</td>
<td class="desout">IPVA macerati</td>
<td class="valout"> R$5.565,62</td>
<td class="situacao">não pago</td>
<td class="delCel"><button class="deletar" href="financeiro_deletar.php?id=38">Deletar</button></td>
</tr>
<table>
达坦
描述
瓦隆
西图昂
17/05/2012
阿特拉索睾丸
R$45,46
帕戈
德莱塔
13/06/2012
马其顿伊普瓦
R$5.565,62
恩帕戈
德莱塔
我做了一个实验:如果我从它读取的单元格html中取出“R$”,问题是,我不知道如何让它忽略“R$”,并且仍然保留在表中(为了可读性)。修改“格式”方法:
format: function(s) {
// format your data for normalization
return parseFloat(s.replace(/[^0-9,]/g, '').replace(',', '.'), 10);
},