tablesorter& amp; Jquery排序价格与欧元符号 [英] Problem with tablesorter & Jquery sorting prices with Euro sign

查看:129
本文介绍了tablesorter& amp; Jquery排序价格与欧元符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题涉及Jquery插件Tablesorter:

My question concerns the Jquery plugin Tablesorter :

我对列出价格的列有问题,格式如下:135.35€,149.99€, 1500€等等

I've a problem with the sorting of a columns with prices, formatted like that : 135.35 €, 149.99 €, 1500 €, etc

排序仅适用于数字,但是当我添加欧元符号时,排序不起作用。

The sorting works well with the numbers only, but when i add the Euro symbol , the sorting is not working anyore.

我有第三列的ASC订单(见下面的代码):

I have this ASC order for the third columns (see code below) :

1)1435€

2)190€

3)834€

你可以看到有什么不对劲。有人可以告诉我该怎么办?

As you can see there's something wrong. Can someone please tell me what should i do here?

非常感谢,

Francois

JS:

<script type="text/javascript" id="js">
    $(document).ready(function() {
    $("table").tablesorter({
    });
});
</script>

HTML :(第3栏需要排序)

<table class="tablesorter" cellspacing="0" cellpadding="0" border="0">             
<thead> 
<tr>
<th width="50px">1</th> 
<th width="120px">2</th> 
<th width="280px" >3</th> 
</tr> 
</thead> 
<tbody> 

<tr>     
<td>bla bla bla</td> 
<td>bla bla bla</td> 
<td>834 €</td> 
</tr> 


<tr>     
<td>bla bla bla</td> 
<td>bla bla bla</td> 
<td>1435 €</td> 
</tr> 


<tr>     
<td>bla bla bla</td> 
<td>bla bla bla</td> 
<td>190 €</td> 
</tr> 

    </tbody> 
</table>


推荐答案

问题是价格列未被识别为数字列并排序为字符串值。您可以强制分拣机类型为数字(请参阅 http://tablesorter.com中的示例/docs/example-meta-parsers.html

The problem is that the price column is not recognized as numeric column and sorted as string values. You could force the sorter type to be numeric (see example in http://tablesorter.com/docs/example-meta-parsers.html)

这篇关于tablesorter&amp; amp; Jquery排序价格与欧元符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆