テーブルソーターの周りをひねって、次のような値で動作させるのにかなりの時間を費やしました: "R $ 3.400,95"言うまでもなく、私は惨めに失敗しました。プロパティを追加しようとしましたheaders: {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>
実験を行いました。セルのhtmlから「R$」を取り出しても問題なく読み取れますが、「R $」を無視してテーブルに残す方法がわかりません(読みやすさのために)。