Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Minimum Input support #274

Closed
philhrmweb opened this issue Oct 9, 2014 · 17 comments
Closed

Minimum Input support #274

philhrmweb opened this issue Oct 9, 2014 · 17 comments

Comments

@philhrmweb
Copy link

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.

@dimirc dimirc added this to the 0.10.x milestone Oct 9, 2014
@kevinswartz
Copy link

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

@masscrx
Copy link

masscrx commented Nov 11, 2014

@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){}

@kevinswartz
Copy link

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

@simkessy
Copy link

simkessy commented Dec 3, 2014

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?

@maxisam
Copy link

maxisam commented Jan 27, 2015

+1

1 similar comment
@jesselpalmer
Copy link

+1

@simkessy
Copy link

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

@dimirc dimirc modified the milestones: 0.12.x, 0.10.x Mar 11, 2015
@reichert621
Copy link

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 😀

@simkessy
Copy link

@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

@thefewminutes
Copy link

+1 minimum input support

@thefewminutes
Copy link

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)

@bunsenmcdubbs
Copy link

+1

@windmaomao
Copy link

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

@windmaomao
Copy link

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
Copy link

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;
    }
}

@abruere
Copy link

abruere commented Dec 18, 2015

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

@user378230
Copy link
Contributor

Implemented in #1291 & d89a869 (v0.14.0)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests