如何使用精确匹配过滤 extjs 存储 [英] how to filter a extjs store with an exact match

查看:31
本文介绍了如何使用精确匹配过滤 extjs 存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为商店使用过滤器.问题是我想返回一个精确匹配.

I am using a filter for a store. The problem is that I want to return an exact match.

例如:

如果我在网格中过滤 aa-1 它将显示 aa-1aa-1*** 但如果我只想查看带有 aa-1 的所有内容.

If I am filtering for aa-1 in a grid it will show aa-1 and aa-1*** but if I want only see everything with aa-1.

我用它来过滤:

listeners: {
    itemclick: function() {
        var data = grid.getSelectionModel().selected.items[0].data;
        store.clearFilter();
        store.filter('productsCat', data.productsCat);
    }
}

我需要做什么才能进行完全匹配?

What do I have to do to do an exact match?

推荐答案

您可以在过滤器中使用正则表达式,以确保比较值是短语的结尾.

You could use a regular expression in the filter to perhaps ensure that the comparison value was the end of the phrase.

或者,或者使用 filterBy() 方法定义一个比较函数,例如:

Either that, or use the filterBy() method to define a comparison function, e.g.:

store.filterBy(this, function(rec, id) {
    if(rec.get('thefieldtocompare') === "what you want to compare against") {
        return true;
    }
    else {
        return false;
    }
});

这篇关于如何使用精确匹配过滤 extjs 存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆