DOJO过滤选择RegExp查询 [英] DOJO Filtering select RegExp query

查看:131
本文介绍了DOJO过滤选择RegExp查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要这样做:

filteringSelect.query = {id: "12|13"};

filteringSelect.query = {id: new RegExp("12|13")};

可以吗?

我是使用ItemFileReadStore作为FilteringSelect的存储。

I am using ItemFileReadStore as a store for that FilteringSelect.

推荐答案

请参阅在dijit.form.ComboBox / dijit.form.FilteringSelect子类上的模糊匹配如果你想去额外的一英里。但是,这是为了过滤用户输入。

See Fuzzy Matches on dijit.form.ComboBox / dijit.form.FilteringSelect Subclass if you want to go the extra mile. This is however for filtering user-input.

为了在打开/输入filteringSelect中的任何内容之前过滤掉条目,请继续执行所有操作。一个简单的字符串不会接受OR运算符,但是使用 RegExp

For filtering away entries before opening/entering anything in the filteringSelect, continue what youre doing allready. A simple string will not accept the OR operator though, use RegExp.

ItemFileReadStore文档查询

var store = new ItemFileReadStore( {
    query: {
       id: new RegExp("/^(12|13)$/")
    }
} );

作为起点,商店中存在所有项目,使用查询引擎的方式是通过 fetch

As a starting point, ALL items are present in the store, the way to make use of the queryengine is through fetch

store.fetch({
        query: { 
          // yes, you can set the query property directly 
          // in the store and leave out this parameter
            id: new RegExp("^(1|12)$")
        },
        onComplete: function(items) {
            dojo.forEach(items, function(item) {
                console.log(store.getValue(item, 'name'))
            });
        }

    })

请参阅 http://jsfiddle.net/LuUbT/ ,例如使用

这篇关于DOJO过滤选择RegExp查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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