繁体   English   中英

sencha touch store 过滤器编号

[英]sencha touch store filter number

我在商店中使用过滤器来查找具有特定数字的条目,但是当我只过滤一个数字时,如果特定数字出现在该数字中,过滤器也会找到其他数字。

store.filter('shiftNum', 1);

在这种情况下,过滤器也可能会找到诸如 10、11、12 等条目。

由于我的商店中只有 21 个可能的数字,因此只有在过滤数字 1 或 2 时才会出现问题。快速解决方法可能是只输入两位数,例如 .01、02。但理论上过滤器应该只搜索数字而不搜索别的。 我尝试更改模型中的字段以指定一个数字字段,与“自动”或“字符串”并列,但无济于事。

Ext.define('Sidur.model.Opt', {
        extend: 'Ext.data.Model',
        config: {
            fields: [
                {name: 'shiftNum', type: 'number'},
                {name: 'name', type: 'string'}
            ],
            proxy: {
                type: 'sqlitestorage',
                dbConfig: {
                    tablename: 'sidur'
                }
            }
        }
    }
);

(顺便说一下数据是本地存储在WebSQL上的)

使用过滤器混合集合甚至自定义函数

store.filter({
  property: fieldName,
  value: fieldValue,
  exactMatch: true,
  caseSensitive: true
});
var longNameFilter = new Ext.util.Filter({
    filterFn: function(item) {
        return item.name.length > 4;
    }
});

http://docs.sencha.com/extjs/5.0.1/#!/api/Ext.util.Filter

使用filterBy

store.filterBy(function(record, id) {
    return record.get('shiftNum') === 1;
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM