• datables自定义排序


    //百分率排序  
    jQuery.fn.dataTableExt.oSort['number-fate-asc']  = function(s1,s2) {  
        s1 = s1.replace('%','');  
        s2 = s2.replace('%','');  
        return s1-s2;  
    };  
      
    jQuery.fn.dataTableExt.oSort['number-fate-desc'] = function(s1,s2) {  
        s1 = s1.replace('%','');  
        s2 = s2.replace('%','');  
        return s2-s1;  
    };  
    //中文排序  
    jQuery.fn.dataTableExt.oSort['chinese-string-asc']  = function(s1,s2) {  
        return s1.localeCompare(s2);  
    };  
    jQuery.fn.dataTableExt.oSort['chinese-string-desc'] = function(s1,s2) {  
        return s2.localeCompare(s1);  
    };   
    2:指定排序的列:
    [javascript] view plain copy print?
    $('#flexme1').dataTable({  
        "aoColumns": [  
            null,  
            { "sType": "chinese-string" },//中文排序列  
            null,  
            { "sType": "number-fate" },//百分率排序  
            null,  
            null  
        ]  
    });  
    jQuery.extend(jQuery.fn.dataTableExt.oSort, {
        "html-percent-pre": function(a) {
            var x = String(a).replace(/<[sS]*?>/g, ""); //去除html标记
            x = x.replace(/&amp;nbsp;/ig, ""); //去除空格
            x = x.replace(/%/, ""); //去除百分号
            return parseFloat(x);
        },
    
        "html-percent-asc": function(a, b) { //正序排序引用方法
            return ((a < b) ? -1 : ((a > b) ? 1 : 0));
        },
    
        "html-percent-desc": function(a, b) { //倒序排序引用方法
            return ((a < b) ? 1 : ((a > b) ? -1 : 0));
        }
    });
    
     "sType": "html-percent",
  • 相关阅读:
    内联汇编的使用
    metamask注记词
    一个简单的增删改查合约
    企业邮箱账号
    压缩包管理
    设计模式
    软硬链接ln
    文件IO-Linux
    静态库和动态库
    gdb调试
  • 原文地址:https://www.cnblogs.com/zjpzjp/p/7640929.html
Copyright © 2020-2023  润新知