如何排序包含带$符号的十进制值的DataTable列-jQuery DataTable [英] How can I sort DataTable Column which is containing Decimal value with $ sign - JQuery DataTable
本文介绍了如何排序包含带$符号的十进制值的DataTable列-jQuery DataTable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,我想对具有以下值的列进行排序:
Hello I want to sort the columns which is having values as follows:
$6.99
$6.49
$10.31
$1.75
$1.02
现在,当我进行排序时,它会认为$ 6.99是最高的,即$ 10.31大于$ 6.99。我访问了一些堆栈问题,并找到了解决方案
Now when I do sorting, it considers $6.99 as the highest, when $10.31 is bigger than $6.99. I visited some stack questions and found this solution
"language": {
"decimal": ".",
}
但是它不能正常工作。这个你能帮我吗。谢谢
But it is not working as well. Please help me out with this. Thank you
推荐答案
使用 num-fmt
作为列的类型在 columnDefs
或 columns
数组选项中:
Use num-fmt
for the type of the column either in the columnDefs
or a columns
array options:
$('#example').dataTable({
"columnDefs": [{
"type": "num-fmt",
"targets": X // X = the index of your currency column
}]
});
这篇关于如何排序包含带$符号的十进制值的DataTable列-jQuery DataTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文