-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Provide option to add no-value choice #302
Comments
I agree, and in addition I would also like an "x" button, even when in single select mode to reset the ui-select to this "empty choice". Is there currently any way to have the "x" button in single select mode? |
@erobwen you can put clear button inside |
just-boris: Is there an example of how to do it? |
Why not just use clear? #287 |
@amcdnl it could be helpful, but it is not quite suitable for me. Here is a plunkr of that what I want to get |
amcdnl: I try to use it with the bootstrap theme (downloaded latest ui-select with bower). Maybe there is something wrong with my setup, or is it not compatible with the bootstrap theme? But I get no result from using "allow-clear", no clear button appears? Another wierd thing is that "propsFilter" from your plunker does not work on my version, I have to type "filter" and only filter on one single property for it to show any items in the dropdown. |
@erobwen - Just to clarify, in their plunker they have implemented the propsFilter in their controller. So if you didn't also implement it, then you wouldn't be able to use it. 'filter' is a default filter provided by ng. |
Does it need to be another directive? Personally, I'd like to move away from so many directives and attributes and more towards a configuration object that could be passed in. This would make it more dynamic. |
@ken4z where you will store that configuration object? |
There would still be a directive, but the null value display name could just be passed in. Instead of making it an additional attribute though, I'd rather have something like
where options is something like
We have a lot of selects that are fairly similar so I'd like to have a wrapper for ui-select that encompasses this commonality with data to change the behavior, changing the properties of an object is easier than adding/removing/manipulating html. But perhaps there is a way you achieve this that I am not aware of. |
+1 For this feature (in combination with bootstrap theme). |
+1 |
11 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
Guys, check this out and tell me if it suits your needs... http://plnkr.co/edit/7nmBRicsmH33E55sSomz edit: jumped the gun, doesn't really add much to what's been discussed above. An interesting consideration is whether or not we'd want to filter to the null option using the search criteria. If so, it would have to be included in the repeat expression array since that's where the filtering occurs. |
That solution looks great to me. In my opinion, it would be best if the null option is not filterable. That way there is always a way to set the box back to null. |
absolutely you are right On 25 February 2015 at 14:39, Jacob [email protected] wrote:
|
@akirich so are you saying that you believe the null option and the clear button should do the same thing? @FFelling As it stands, the code I've written isn't really adding a lot of support for null option stuff considering that the user still has to specify it in their collection. Perhaps I'll modify the functionality so that:
As far as displaying the null option is concerned (i.e. "Please select XYZ"), I am leaning towards reusing the template provided inside the choices element to provide the most flexibility. I've had templates that are quite complex and would require control over how the null option is displayed (it wouldn't just be a string). In this case, if the items in the original collection were just strings I could write I am not clear yet on the best relationship between the clear button and the null option... Any thoughts? |
yes. I believe clear button (which would set value to null) and placeholder On 26 February 2015 at 14:57, Daniel Zimmermann [email protected]
|
@akirich isn't this what |
yes ! it didn't work for me as I've found we already have modified On 26 February 2015 at 15:19, Daniel Zimmermann [email protected]
|
This issue has some history. Some time ago there was no generic way to clear ui-select when using the bootstrap template. There was no clear button and no null option. The only option was to add a null-item to the data collection prior to binding. The clear button has since been added and works as expected. We still would like to have a null option that is not part of the original data collection. When it is specified and you press the clear button the null option should be selected when present. I like @dlukez proposed solution (null-option="{ name: 'Please Select XYZ' }") for it's flexibility. |
I'm currently using the placeholder to specify the description of the null option, but it is a bit weird, would really like to have an explicit null-option |
+1 |
I am trying to figure out how to use ui-select to emulate google style search (i.e., where the user can search any string they want or select something from the menu in the dropdown). Is this possible? right now, I can only get onselect function to trigger when i select an item from the menu and not when they just type in a random string that doesn't match anything. |
Will the null-option support be included for a multiple select? |
+1 |
3 similar comments
+1 |
+1 |
+1 |
My problem with the allow clear button is that if I were to use only keyboard, I would have no way to clear the value in my dropdown, but if we had a null option, then I could simply delete my search text and choose my null option. |
+1 |
6 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
Hello, folks. I tried to implement this feature, but it is more complicated that it seemed initially. ui-select has very difficult transclusion logic, so I can't insert one more nested directive and inject it into dropdown. Also, I found a fix in a related project: RenovoSolutions/TypeScript-Angular-Components#91. Here it was done via extra configutation option for main directive itself. Maybe we here should do the same. |
Is this allow-clear option a newly added one ? For me, adding allow-clear="true" doesn't make any effect. I am using ui-select theme select2 3.5.1. |
@jibusayone |
Thanks for the comment @just-boris I just found out the issue. It was the version which was causing the problem. |
Could someone clarify, this thing is not ready yet? I need the same thing that in OP post, a way to add "-- please select--" option to dropdowns. |
Angular.js select directive have a convenient way to define null-value option. If you put
<option>
tag without value inside<select>
, it will be treated as null-option which sets model value tonull
.It is useful sometimes to provide user ability to reset selected value. Now I have to implicitly add that item to other choices in repeat.
I don't want to do it and it would be good if you will have an option for provide this option through html, for example
It is similar to select directive logic and looks good for me. What do you think?
The text was updated successfully, but these errors were encountered: