2

考虑用户必须从数千个值的列表中选择多个值的情况。我最接近可用工具的是http://quasipartikel.at/multiselect/

主要问题是由于用户必须从中选择的大量数据。我目前使用的方法是用户必须在文本框中输入第一个字符,然后应显示以第一个字符开头的所有值以进行多选。(因此过滤到一个相当大的值列表)

问题是即使值的数量如此之大,重新加载多选选项也需要 5-15 秒。但是一旦加载了值,javascript 过滤就会处理其余的,因为用户输入了后续字符。

关于解决这种情况的任何其他方法的任何建议????

4

2 回答 2

1

Instead of using a multiselect box that is pre-populated use jQueryUI Autocomplete to filter the list server side and only return matches to the client (similar to the way the tag selection works on StackOverflow).

There is a good example of selecting multiple values here http://jqueryui.com/autocomplete/#multiple-remote

You can then save the results of the selections in the same way you would process a multiselect.

To implement a hybrid approach where the first letter fetches terms from the server and then afterwards filters from those results, you could use the following (please note that this is completely untested):

Add a global var to hold your results

var results_cache = [];

Use a hybrid source in your autocomplete

source: function( request, response ) {
    // get the first letter of your search term
    var letter = request.term.substring(0,1);
    // check to see if we already have results for this letter
    if (!results_cache[letter]){
        // no results, fetch via AJAX
        $.getJSON( "search.php", { term: request.term }, 
            function(data){ 
                // cache results
                results_cache[letter] = data;
                // filter results (in case we have more than just 1 character in the term)
                response($.ui.autocomplete.filter(data, request.term));
            }
        );
    } else {
        // we already have data for this letter, just filter the results from the cache
        response($.ui.autocomplete.filter(results_cache[letter], request.term));
    }
},
search: function() {
    // make sure we have at least 1 character for the term
    if (!this.value) return;
    var term = this.value;
},
于 2012-10-29T15:42:10.523 回答
0

The following were helpful:

First, filter the values based on certain input parameters, before selecting the final large size input. Secondly, increasing the limit from one character to multiple before the jquery select values are loaded. This shall limit the number of values further, but the user shall have to be aware of the multiple character input limit

But http://quasipartikel.at/multiselect/ still feels the best avaliable option out there.

于 2012-10-29T15:41:54.087 回答