dijit.form.select 下拉菜单非常慢
将 3000 个值加载到 dijit.form.select 控件中需要更长的时间。即使有 500 个值,浏览器也会挂起。如何克服这个问题呢?
任何帮助将不胜感激。
谢谢, 卡蒂克·K.
Loading 3000 values into dijit.form.select control takes longer time. browser gets hanged even for 500 values. How to over come this problem?
Any assistance would be really appreciated.
Thanks,
Karthihck k.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 3,000 个任何内容加载到网页中总是会很慢。
尽管有一些扭曲的方法可以克服此限制,但对于您的用户来说这可能不值得,因为他们肯定不喜欢滚动浏览 3,000 个项目来选择一个!
我建议您将此下拉列表分为两级(或三级),每级的选择不要超过 20-30 个。在我自己的一个包含数千个列表项的项目中,我必须使用四个级别,否则性能会很糟糕。
如果您只有一个长列表可供使用,请考虑按起始字母将其分为 26 组,例如电话列表。至少每组只有 100-200 人。
现在,如果您真的想要加载这么长的列表,请考虑不要使用
dijit.form.Select
,因为它只是的简单包装器。选择>
标签。您实际上是一次插入一个标记,从而降低了性能。您有两种选择:
标记列表,然后一次性插入到
dijit.form.FilteringSelect
。现在,我绝对不赞成这样做。你已被警告过!
Loading 3,000 of anything into a web page is always going to be slow.
Although there are twisted ways to overcome this limitation, it may not be worth it for your user is definitely not going to like scrolling through 3,000 items to pick one!
I'd suggest you break this drop-down list into two (or three) levels, and have no more than 20-30 choices each. In one of my own projects with thousands of list items, I had to go with four levels, otherwise performance gets abysmal.
If you only have one long list to work with, consider breaking it down by the starting letter into 26 groups, like a phone list. At least you'll have only 100-200 in each group.
Now, if you really really want to load such a long list, consider not using
dijit.form.Select
as it is just a simple wrapper for the<select>
tag. You're essentially inserting one<option>
tag at a time, killing performance. You have two choices:<option>
tags yourself off-line, then insert into the<select>
element in one go.dijit.form.FilteringSelect
instead.Now, I definitely don't endorse doing the above. You've been warned!