简体   繁体   English

任何与jQuery 1.3兼容的插件,都可以使用用户文本输入加上基于匹配的输入字符串数进行分组来过滤下拉列表

[英]Any jquery 1.3 compatible plugin to filter dropdown using user text input plus grouping based on number of input strings matched

Just wanted to know if there already is plugin for this, otherwise I am going to code myself. 只是想知道是否已经有用于此的插件,否则我将自己编写代码。 Following is my exact requirement. 以下是我的确切要求。

Say I have a dropdown list like this - 假设我有一个这样的下拉列表-

<select id="values" name="country">
  <option value="1">Hello world</option>
  <option value="2">Hello there</option>
  <option value="3">Hello again</option>

  <option value="4">Andorra</option>
  <option value="5">Argentina</option>
  <option value="6">Armenia</option>
  <option value="7">Aruba</option>
  <option value="8">Australia</option>
  <option value="9">Austria</option>
  ...
</select>

And there is an input field for the user to filter the dropdown contents. 并且有一个输入字段供用户过滤下拉列表内容。 So it looks like this in the beginning - 所以一开始看起来像这样-

在此处输入图片说明

Use Cases (Requirements) 用例(需求)

Obvious case of single word entry -> User enters "Hello" 单个单词输入的明显情况->用户输入“ Hello”

Result should have only options containing "Hello" 结果应仅包含“ Hello”的选项

<select id="values" name="country">
      <option value="1">Hello world</option>
      <option value="2">Hello there</option>
      <option value="3">Hello again</option>
</select>

When Multiple words entered -> eg "Hello again", OR logic should be applied on the options and options containing any of the words should be remaining. 当输入多个单词->例如“再次问好”时,应在选项上应用OR逻辑,并且应保留包含任何单词的选项。

<select id="values" name="country">
  <option value="3">Hello again</option>
  <option value="2">Hello there</option>
  <option value="1">Hello world</option>      
</select>

A further enhancement which I am looking for is to group the results on the basis of number of words matched, all words matches at the top, followed by lesser words matches till the end, something like this - 我正在寻找的另一项增强功能是,根据匹配的单词数对结果进行分组,所有单词均在顶部匹配,然后再进行次要的单词匹配,直到末尾,如下所示:

在此处输入图片说明

I know this is a very specific requirement, but still gave a try... 我知道这是一个非常具体的要求,但还是尝试了一下。

I checked this question Jquery: Filter dropdown list as you type and some plugin demos given there, but did not find exactly what I am looking for. 我在输入时检查了这个问题“ jQuery:过滤器下拉列表”,并在其中给出了一些插件演示,但没有找到我想要的东西。 The first part JQuery UI MultiSelect has the OR search logic I am looking for, but without the grouping. 第一部分JQuery UI MultiSelect具有我要查找的OR搜索逻辑,但没有分组。 But that needs jquery 1.5 and the older version which works with jquery 1.3 does not have the input field. 但这需要jquery 1.5,并且与jquery 1.3兼容的旧版本没有输入字段。

My honest opinion would be that the best route here would be to write your own custom code for this problem. 我的诚实观点是,最好的方法是为这个问题编写您自己的自定义代码。 jQuery (use 1.6 by the way) is very powerful and can solve your issue but finding a specific plugin which meets your needs exactly is unlikely. jQuery(顺便使用1.6)非常强大,可以解决您的问题,但是不太可能找到一个完全能够满足您需求的特定插件。

Maybe you should take an already existing plugin such as: 也许您应该使用一个已经存在的插件,例如:

http://docs.jquery.com/Plugins/autocomplete http://docs.jquery.com/Plugins/autocomplete

and then reconfigure it to show the results in the way you want. 然后重新配置它,以所需的方式显示结果。 Then publish your code back to the community and help to add to the rich collection of plugins available. 然后将您的代码发布回社区,并帮助添加到可用插件的丰富集合中。

Just a thought. 只是一个想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM