我的货币标签中的数据表排序出现问题。当我尝试对货币/价格列进行排序时..
实施例
A - $ 10,0000
B - $ 4,000
C - $ 8,000
在Chrome中:
它工作正常,显示正确的答案。这是BCA
升序。
在Mozilla和IE中:
它没有显示正确的答案,而是会显示此答案ACB
升序。我相信它读取自moz以来的第二低数字,iE将$符号作为字符串的一部分读取。
对此有何解决方案?
您可以尝试我找到的此示例link 在Chrome和Mozilla中打开它
答案 0 :(得分:0)
我只是解决了我的问题。
而不是为导致错误的货币插件创建扩展的.js文件。我将代码与创建数据表对象一起编写。像这样的东西:
$(document).ready(function(){
model_select();
$('.data_table').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bRetrieve":true,
"aoColumnDefs": [
{ "sType": "currency", "aTargets": [ 10 ] }
]
});
// Change this list to the valid characters you want
var validChars = "$£€c0123456789-,";
// Init the regex just once for speed - it is "closure locked"
var str = jQuery.fn.dataTableExt.oApi._fnEscapeRegex("$£€c0123456789-,");
var re = new RegExp('[^'+str+']');
jQuery.fn.dataTableExt.aTypes.unshift(
function ( data )
{
if ( typeof data !== 'string' || re.test(data) ) {
return null;
}
return 'currency';
}
);
});