超过 300 行的下拉列表的最佳解决方案?

发布于 2024-12-22 02:05:51 字数 242 浏览 4 评论 0原文

我遇到了这个问题,在一个表单中,我有一个可能超过 300 个的客户列表,对我来说,在那里查找并不是很简单,因为我应该滚动所有结果才能找到一行!

在旧技术上,我有一个按钮,打开一个弹出窗口,我应该在其中研究应该选择哪个客户,然后我使用 JavaScript 来记录第一个表单上的选择,但这可能是新技术的一个很好的解决方案!

我该如何解决这个疑问呢?大

I have this problem, in a form I have a list of customers that could be more than 300 and, for me, it isn't very simple find over there because I should scroll all results for find a single row!

On the old technology I had a button that opened a pop up where I should research which customer I should select and than I used a javascript for recording the selection on the first form, but It could be a good solution with new technology!

How can I resolve this doubt? What is the best solution for big <select> tag?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

多彩岁月 2024-12-29 02:05:51

您基本上需要一个自动完成下拉列表。标准 JSF 组件集中不存在这种情况,并且在标准 JSF 组件集中使用 JavaScript/jQuery 实现也并非易事,因为可用值必须存在于服务器端的状态中。您基本上还需要一个由

  • 表示的下拉列表,而不是 不允许最终用户输入文本。标准 JSF 组件集没有呈现所需 HTML 的组件标记。您基本上需要创建一个自定义 JSF 组件。

有第 3 方 JSF 组件库已经提供了完整的 JSF 自动完成下拉列表。使用它们中的任何一个都会更容易,而不是通过自定义 JSF 组件重新发明轮子。选择您的选择:

You basically want an autocomplete dropdown list. This does not exist in the standard JSF component set and it is also not exactly trivial to implement with JavaScript/jQuery on top of the standard JSF component set because the available values have to be present in the server side's state. You also basically want a dropdown list which is represented by a <div><input><ul><li> instead of a <select><option> because a normal <select> doesn't allow the enduser to type text in. The standard JSF component set does not have a component which renders the desired HTML markup. You'd basically need to create a custom JSF component.

There are 3rd party JSF component libraries which already offer a fullworthy JSF autocomplete dropdown list. It would be easier to use either of them instead of reinventing the wheel by a custom JSF component. Take your pick:

虫児飞 2024-12-29 02:05:51

是的,当您有大量项目时,jQuery 自动完成插件是您的最佳解决方案。

顺便说一下,想象一下您想要选择一个带有特定字母的项目。当您使用下拉列表时,您可以通过输入每个项目的第一个字母的名称来指向您想要的项目。但是使用 jQuery 自动完成,您可以在任何地方搜索一个字符串或一组字母。无论您插入的字母是位于项目名称的第一个还是其他位置,都没有关系。

正如 ShantanuD 所说,你可以在 http://jqueryui.com/demos/autocomplete/ 中找到这个插件

Yes, the jQuery autocomplete plugin is the best solution for you while you have a large number of items.

By the way, imagine that you would like to select an item with specific letters. While you are using drop down lists, you can point to your wanted items by typing their names from the first letter of each one. But using jQuery autocomplete, you can search a string or a group of letters in everywhere. it does not matter if are your inserted letters located at the first of your item names or in other places.

As ShantanuD said, you can find this plugin in http://jqueryui.com/demos/autocomplete/

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