表分拣机货币清理
Tablesorter currency cleaning
我花了很多时间在 twick arround tablesorter 上让它处理诸如"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$"并仍然将其留在表中(为了可读性)。
修改 'format' 方法:
format: function(s) {
// format your data for normalization
return parseFloat(s.replace(/[^0-9,]/g, '').replace(',', '.'), 10);
},
相关文章:
- 货币代码为欧元-金额的格式不应包含小数
- 将数字四舍五入到小数点后两位,以设置货币格式
- '图片'没有用于本机道具的propType'RCTImageView.overlayColor&
- 在iOS和Android上使用React native时,我还能使用本机第三方lirbraries吗
- 带Js的货币转换器
- 使用JAVASCRIPT转换货币.可以't通过我的函数设置转换后的输入文本字段的值
- javascript函数访问ios本机功能
- 如何在从客户端接收数据时从本机方法触发javascript函数?
- 在浏览器中检测本机或第三方PDF插件
- 格式化货币无效
- 浏览器intl.NumberFormat未正确显示货币符号
- JS toLocaleString始终显示货币符号,而不考虑区域设置
- 将事件发送到javascript文档的react本机模块是否正确
- 将对应用内购买的支持构建为react本机代码
- 如何在Windows上用javascript构建本机应用程序
- 在Javascript中,对于货币来说,是toFixed()足够精确
- 在视图中渲染多个按钮以编程方式进行本机反应
- 在本机挂钩之前加载可安装挂钩
- 如何使用UI Automation JavaScript Reference for iOS appium获取本机应用程
- 如何将字符串地址传递到传单路由机,以根据字符串地址获得方向