过滤大选择列表 [英] Filtering Large Select Lists

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

问题描述

大家好,


我有一份约1600名员工的名单,我想在表格中显示

。我想做一个搜索对于用户来说很简单

可能。


我碰到了这个: http://www.barelyfitz.com/projects/filterlist/

过滤器适用于小型列表(在该网站是

20个名字的名单)。它在Firefox 1.5中运行良好,但在IE浏览器中爬行

6.


我的意思是爬行是需要大约30秒才能过滤掉

在IE 6中列出,而在Firefox 1.5中则为1。


我可以编写一个Ajax解决方案,该解决方案应该花费不到3秒,但是

想要使用类似客户端的东西,因为操作

看起来很简单。


有什么建议吗?


非常感谢任何帮助!


凯文

Hello everyone,

I have a list of about 1600 employees that I''d like to have displayed
in a form. I''d like to make the "search" for the user as easy as
possible.

I ran across this: http://www.barelyfitz.com/projects/filterlist/
filter that works quite well with small lists (on the site is a list of
20 names). It also works quite well in Firefox 1.5, but crawls in IE
6.

What I mean by crawls is that it takes about 30 seconds to filter the
list in IE 6 versus about 1 in Firefox 1.5.

I can code an Ajax solution that will should take under 3 seconds, but
would like to use something client side like this since the operation
seems simple.

Any suggestions?

Any help is greatly appreciated!

Kevin

推荐答案

嗨凯文,
Hi Kevin,
大家好,

我有一份大约1600名员工的名单,我希望在表格中显示
。我想做一个搜索对于用户而言,这很简单。

我碰到了这个: http://www.barelyfitz.com/projects/filterlist/
过滤器适用于小型列表(在网站上列出了20个名字) )。它在Firefox 1.5中也运行得很好,但是在IE浏览器中爬行
6

我的意思是爬行是因为在IE 6中过滤
列表大约需要30秒与Firefox 1.5中的大约1相比。

我可以编写一个应该花费不到3秒的Ajax解决方案,但
想要使用像客户端这样的东西,因为操作
看似简单。

有什么建议吗?

非常感谢任何帮助!

Kevin
Hello everyone,

I have a list of about 1600 employees that I''d like to have displayed
in a form. I''d like to make the "search" for the user as easy as
possible.

I ran across this: http://www.barelyfitz.com/projects/filterlist/
filter that works quite well with small lists (on the site is a list of
20 names). It also works quite well in Firefox 1.5, but crawls in IE
6.

What I mean by crawls is that it takes about 30 seconds to filter the
list in IE 6 versus about 1 in Firefox 1.5.

I can code an Ajax solution that will should take under 3 seconds, but
would like to use something client side like this since the operation
seems simple.

Any suggestions?

Any help is greatly appreciated!

Kevin




好​​吧,我可以想象,一个纯粹的客户端-JS-Function过滤列表

的1600名员工总是需要一点额外的时间。我的意思是你有一个接一个地将1600个元素的正则表达式应用到了
- 恕我直言不是一个好主意。

AJAX-Solution应该是更好的方法,服务器就是你有更多的

可以过滤数据。


martin



Well, I could imagine, that a pure clientside-JS-Function for Filtering a list
of 1600 employees will allways need a little bit of extra time. I mean you have
to apply a regex to 1600 elements one after the other - IMHO not a good idea.
The AJAX-Solution should be the better way, serverside you have much more
possibilities to get the data filtered.

martin


< ke * *****@gmail.com>在消息新闻中写道:11 ********************** @ f14g2000cwb.googlegr oups.com ...
<ke******@gmail.com> wrote in message news:11**********************@f14g2000cwb.googlegr oups.com...
大家好,

我有一份大约1600名员工的名单,我想在表格中展示
。我想做一个搜索对于用户而言,这很简单。

我碰到了这个: http://www.barelyfitz.com/projects/filterlist/
过滤器适用于小型列表(在网站上列出了20个名字) )。它在Firefox 1.5中也运行得很好,但是在IE浏览器中爬行
6

我的意思是爬行是因为在IE 6中过滤
列表大约需要30秒与Firefox 1.5中的大约1相比。

我可以编写一个应该花费不到3秒的Ajax解决方案,但
想要使用像客户端这样的东西,因为操作
看似简单。

有什么建议吗?
Hello everyone,

I have a list of about 1600 employees that I''d like to have displayed
in a form. I''d like to make the "search" for the user as easy as
possible.

I ran across this: http://www.barelyfitz.com/projects/filterlist/
filter that works quite well with small lists (on the site is a list of
20 names). It also works quite well in Firefox 1.5, but crawls in IE
6.

What I mean by crawls is that it takes about 30 seconds to filter the
list in IE 6 versus about 1 in Firefox 1.5.

I can code an Ajax solution that will should take under 3 seconds, but
would like to use something client side like this since the operation
seems simple.

Any suggestions?




IE众所周知,在解析表格属性方面相对较慢。

看看这两个变化有什么影响。我可以看到其他优化,但它们更难列出。


在init方法中,替换


for(var i = 0 ; i< this.selectobj.options.length; i ++)


with


for(var i = 0,len = this。 selectobj.options.length; i< len; i ++)

并在set方法中,替换


for(loop = 0; loop< this .optionscopy.length; loop ++)


with:


var len;

for(loop = 0, len = this.optionscopy.length; loop< len; loop ++)

-

SC



I.E. is known to be relatively slow at resolving form properties.
See what effect these two changes have. I can see other optimisations but they''re harder to list.

In the init method, replace

for (var i=0; i < this.selectobj.options.length; i++)

with

for (var i=0, len=this.selectobj.options.length; i < len; i++)
and in the set method, replace

for (loop=0 ; loop < this.optionscopy.length; loop++)

with:

var len;
for (loop=0, len=this.optionscopy.length; loop < len; loop++)

--
S.C.


ke******@gmail.com 写道:
大家好,

我有一份约1600名员工的名单,我想在表格中展示。我想做一个搜索对于用户而言,这很简单。

我碰到了这个: http://www.barelyfitz.com/projects/filterlist/
过滤器适用于小型列表(在网站上列出了20个名字) )。它在Firefox 1.5中也运行得很好,但是在IE浏览器中爬行
6

我的意思是爬行是因为在IE 6中过滤
列表大约需要30秒与Firefox 1.5中的大约1相比。

我可以编写一个应该花费不到3秒的Ajax解决方案,但
想要使用像客户端这样的东西,因为操作
看似简单。

有什么建议吗?

非常感谢任何帮助!
Hello everyone,

I have a list of about 1600 employees that I''d like to have displayed
in a form. I''d like to make the "search" for the user as easy as
possible.

I ran across this: http://www.barelyfitz.com/projects/filterlist/
filter that works quite well with small lists (on the site is a list of
20 names). It also works quite well in Firefox 1.5, but crawls in IE
6.

What I mean by crawls is that it takes about 30 seconds to filter the
list in IE 6 versus about 1 in Firefox 1.5.

I can code an Ajax solution that will should take under 3 seconds, but
would like to use something client side like this since the operation
seems simple.

Any suggestions?

Any help is greatly appreciated!




除了来自的建议斯蒂芬,你可能想研究一下b $ b查找算法。 ''filterlist''根本没有优化,每次都会搜索所有选项的每个选项(尽管每个

搜索列表确实减少了)。它会复制整套选项,然后删除

不匹配的选项。


如果有这么大的列表,排序你的排序可能要快得多选项

并为第一个搜索字符创建密钥。您可以为以A,B,C等开头的选项创建单独的

数组(或者一些优化的

组键)。因此,在第一次按键时,你只需要过滤''选项

从该字母开始(只需从相应的

数组或索引键创建一个选项)。无论是键还是数组更快/更好都需要进行少量测试。


后续过滤应该在没有更多匹配时立即停止处理
找到
- 即使找到最后一个匹配,filterlist也会继续运行。


我不确定filterlist使用的对象方法是否适用于此

流程 - 它非常优雅但是对象通常用于

软件设计师或程序员的方便,而不是因为它更快。

有时候你最好将功能减少到仅需要
(不区分大小写的搜索,从左到右,仅从第一个字符的
开始),并以纯粹的方式实现它程序方式。


祝你好运。


-

Rob



In addition to the suggestions from Stephen, you may want to research
lookup algorithms. ''filterlist'' is not optimised at all, it searches
all the options every time (though the list does reduce with each
search). It copies the entire set of options, then removes the
non-matching ones.

With such a large list, it is probably much faster to sort your options
and create keys for the first search character. You may create separate
arrays for the options starting with A, B, C, etc. (or some optimised
set of keys). So at the first key press you ''filter'' to only options
starting with that letter (just create a select from the appropriate
array or index key). Whether keys or arrays are faster/better will take
a small amount of testing.

Subsequent filtering should stop processing as soon as no more matches
are found - filterlist keeps going even when the last match has been found.

I''m not sure the object approach used by filterlist is optimal for this
process - it is quite elegant but objects are usually there for the
software designer or programmers'' convenience, not because it is faster.
Sometimes you are better off to reduce the functionality to only what
is required (say case insensitive search, left to right and only from
the first character) and implement it in a purely procedural manner.

Good luck.

--
Rob


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

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