dijit过滤以最小长度选择 [英] dijit filteringSelect with min length

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

问题描述

我似乎找不到要求过滤选择输入为一定长度的方法。我试过这样:

I can't seem to find a way to require the filtering select input to be of a certain length. I've tried like this:

new dijit.form.FilteringSelect({
    'name': 'bla',
    'store': jsonRestStore,
    'searchAttr': "name",
    'pattern': '.{3,}',
    'regExp': '.{3,}'
});

但它不会改变一件事情。如果至少输入3个字符,我想要过滤选择仅查询商店。不能是异国情调的要求吗?这个商店后面有数千个项目,所以只用1个或2个字符进行查询很慢。

but it doesn't change a thing. I want the filtering select to only query the store, if at least 3 characters have been entered. Can't be that exotic a requirement, can it? There are thousands of items behind that store, so querying that with just 1 or 2 characters is slow.

推荐答案

我做了一点更多搜索,并在dojo邮件列表中找到此帖。总而言之,FilteringSelect的本机支持是无法实现的,但实现起来非常简单。

I did a bit more searching and found this post on the dojo mailing list. To summarize, there is no way to native support in the FilteringSelect for it, but it is extremely easy to implement.

// custom min input character count to trigger search
minKeyCount: 3,

// override search method, count the input length
_startSearch: function (/*String*/key) {
    if (!key || key.length < this.minKeyCount) {
    this.closeDropDown();
    return;
    }
    this.inherited(arguments);
}

另外在 API文件,有一个 searchDelay 属性,可以帮助最小化查询数量。

Also in the API Docs, there is a searchDelay attribute, which could be helpful in minimizes the number of queries.

searchDelay 
Delay in milliseconds between when user types something and we start searching based on that value

这篇关于dijit过滤以最小长度选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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