easyui datagrid filter 空字符串、数字过滤bug修复

datagrid filter 空字符串匹配过滤不掉,数字类型当成字符类型过滤(0,1)过滤0时候的问题

特贴出一下修复代码:

contains 匹配修改:

<!-- lang: js -->
contains: {
        text: 'Contains',
        isMatch: function(source, value){
            if(typeof(source) == "number"){
                return String(source).toLowerCase().indexOf(value.toLowerCase()) >= 0;
            } else {
                return source.toLowerCase().indexOf(value.toLowerCase()) >= 0;
            }
        }
    }
<!-- lang: js -->
function isMatch(row){
        var rules = opts.filterRules;
        for(var i=0; i<rules.length; i++){
            var rule = rules[i];
            var source = row[rule.field];
            if (source || source == "" || typeof(source) == "number"){
                var op = opts.operators[rule.op];
                if (!op.isMatch(source, rule.value)){return false}
            }
        }
        return true;
    }

你可能感兴趣的:(easyui datagrid filter 空字符串、数字过滤bug修复)