ui-select icon indicating copy to clipboard operation
ui-select copied to clipboard

Minimum Input support

Open philhrmweb opened this issue 12 years ago • 17 comments

There does not seem to be support for a minimum input length prior to searching? (Same as select2's Minimum Input)

Particularly in large data sets it means searching is rather slow, and 1-2 character search terms are not particularly useful.

philhrmweb avatar Oct 09 '14 04:10 philhrmweb

I would also love this! In the meantime is there any workaround?

kevinswartz avatar Nov 05 '14 00:11 kevinswartz

@kevinswartz I've made workaround like this: http://pastebin.com/dcfE07pg so 1.refresh="checkCountry($select.search)" - function fired after user enter some characters and then in this function if (country_name.length >= 3){}

masscrx avatar Nov 11 '14 09:11 masscrx

@masscrx Thanks! I actually ended up implementing nearly the same thing the other day.

kevinswartz avatar Nov 11 '14 16:11 kevinswartz

I don't really understand this line: DataFactory.search('countries', country_name, 1, 20)

I have an init function that provides a full list of users for my select for example:

<ui-select-choices repeat="User in User.collection | filter: $select.search">

init: function (){
                UserService.loadUsers().then(function (result){
                    User.collection = result;
                });   
            },

How could I implement a limit like you have into this for example?

EDIT: Even the result.plain() could you explain what that does?

simkessy avatar Dec 03 '14 07:12 simkessy

+1

maxisam avatar Jan 27 '15 16:01 maxisam

+1

jesselpalmer avatar Jan 27 '15 19:01 jesselpalmer

Was this missed in the milestone. We're on 11.1 now but the milestone was set to 10 :/

simkessy avatar Mar 11 '15 06:03 simkessy

Using angular's limitTo in the repeater would probably help: <ui-select-choices repeat="item in items | filter: $select.search | limitTo: 50">

Fixed the slowness for me, at least :grinning:

reichert621 avatar May 14 '15 22:05 reichert621

@reichert621 So I tested it and it turns out that limitTo does what I expected. It returns only the n value specified and nothing else, and there's no pagination until Angular 1.4 with the begin parameter. So I'm guessing you can use some function to update the begin value dynamically.

https://code.angularjs.org/1.4.0-beta.6/docs/api/ng/filter/limitTo

simkessy avatar May 15 '15 21:05 simkessy

+1 minimum input support

thefewminutes avatar Jun 25 '15 22:06 thefewminutes

line 313 in select.js: if (!ctrl.disabled && !ctrl.open && ctrl.search.length > 2) also line 1359: if ($select.tagging.isActivated && $select.search.length > 2)

thefewminutes avatar Jul 16 '15 20:07 thefewminutes

+1

bunsenmcdubbs avatar Jul 22 '15 17:07 bunsenmcdubbs

looking forward to 0.13.3 for this commit, hopefully we can make this length as an option.

windmaomao avatar Nov 21 '15 15:11 windmaomao

this commit is a bit too much, on dist ? and also it only changes two lines, but the file look like it changed a lot of places.

windmaomao avatar Dec 17 '15 23:12 windmaomao

ok, the above commit does not work at all, and i find a easy way using just css, here's the solution.

<ui-select ng-model="selectedItem">
    <ui-select-match>...</ui-select-match>
    <ui-select-choices repeat="item in (itemArray | filter: $select.search | limitTo:10) track by item.id" group-by="'type'" ng-class="{hide: $select.search.length < 3 }">
                                    ...
    </ui-select-choices>
</ui-select>

now you can just set the css to be

.ui-select-choices {
    &.hide {
        display: none;
    }
}

windmaomao avatar Dec 18 '15 00:12 windmaomao

Sorry, I did not intend to reference this issue from my fork (lot of useless changes indeed, due to my text editor removing trailing spaces).

Thank you @thefewminutes anyway for your idea !

This worked for me, but I'll try your css @windmaomao, thanks !

+1 optional minimum length support

abruere avatar Dec 18 '15 00:12 abruere

Implemented in #1291 & d89a869d53b918724d7a8a4c6cbcc90c477e21ea (v0.14.0)

user378230 avatar Jan 28 '16 13:01 user378230