dijit.form.select 下拉菜单非常慢

发布于 2024-10-22 03:39:26 字数 133 浏览 1 评论 0原文

将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

林空鹿饮溪 2024-10-29 03:39:26

将 3,000 个任何内容加载到网页中总是会很慢。

尽管有一些扭曲的方法可以克服此限制,但对于您的用户来说这可能不值得,因为他们肯定喜欢滚动浏览 3,000 个项目来选择一个!

我建议您将此下拉列表分为两级(或三级),每级的选择不要超过 20-30 个。在我自己的一个包含数千个列表项的项目中,我必须使用四个级别,否则性能会很糟糕。

如果您只有一个长列表可供使用,请考虑按起始字母将其分为 26 组,例如电话列表。至少每组只有 100-200 人。

现在,如果您真的想要加载这么长的列表,请考虑不要使用dijit.form.Select,因为它只是的简单包装器。选择> 标签。您实际上是一次插入一个 标记,从而降低了性能。您有两种选择:

  1. 自己离线创建 标记列表,然后一次性插入到
  2. 请考虑使用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:

  1. Create the list of <option> tags yourself off-line, then insert into the <select> element in one go.
  2. Consider dijit.form.FilteringSelect instead.

Now, I definitely don't endorse doing the above. You've been warned!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文