Glitch fix for chosen multiselect dropdown - javascript

Example Fiddle
Description:
I have applied chosen plugin for a multiselect dropdown
The first option is "Any"
Those who are accustomed with chosen dropdown,they know that when an option is selected(from chosen multiselect) and presented in the dropdown textarea-like field, you will see it disabled from the list menu automatically.
When the first option "Any" is be selected, then all the other options from the list menu is also disabled.
When the "Any" option is removed from the dropdown textarea-like field(deleting by clicking on the cross with the selected option),then again all the options are enabled.
Requirement:
If we select any option from the dropdown, then its presented in the textarea-like filed, denoting that its being selected.
First select any option except "Any".
It will be displayed on the textarea-like field.
Now Select "Any".
Any will be displayed in the textarea-like field, and the previously selected option(s) is also being displayed in the textarea-like field.
I need the previously options selected to be removed from the textarea-field
How can I achieve this functionality?

You can define what happens in your if statement that checks to see if the Any option is selected
if (params.selected && params.selected == "Any") {
// disable the select
$('.chosen-select').val('Any'); // Select Any and remove everything else
And here is a demo

Related

Unselect the select box once isClearable is clicked or true

I wanted to unselect the Input box once the close button is selected after the option is selected
I have attached codesandbox link
Current output
When user select the option value is displayed when close icon is clicked it removes the option but select box is selected unless you click outside, it un-selects the box
expected output
When user select the option value is displayed when close icon is clicked it removes the option and un-selects the box as well.
You are talking about something named 'focus'.
This is actually built-in browser behavior, so if you want it to lose focus in some cases you can do it programmatically using refs.
Here is a link to guide where you can find how to do it

ng-select multiple checkbox selection

When there are multiple checkbox options inside dropdown I don't want them to apply on each selection.
I would like to do like this : After checking few options, user has to click the apply button inside the dropdown then the options will get selected. If user doesn't click apply his selection will get reset.
Also I would like to show the selected option like this, instead of showing all the options inside the dropdown. If there is more than one option selected user will se (+1 other) or anything other text
The versions I'm using:
Angular Version: 7.3.7,
Ng-select Version:2.20
Can anyone help?

Disable re-select when model was selected in Angularjs-chosen

I need help with the following scenario:
I use a single-select dropdowns in a table. Each row has its own dropdown.
Now there are 2 options for changing the selection:
Click on deselect ('x') icon (works ok - via ng-change).
Open the dropdown, choose another value from list. Override the previous value (although ng-change fires, I have no way to know if it's a new value or a overriding value).
I wish to disable the second behavior. Is it possible to 'tell' chosen that once a value was selected, the only way to re-select a new value is to click on 'x'?
e.g: once a value was selected, disable the dropdown, hide the 'arrow' icon, but keep the 'x' deselect icon active?
<select chosen
allow-single-deselect="true"
placeholder-text-single="'Select'
ng-model="row.userSelection"
ng-options="field as field.name for field in vm.fields">
<option value=""></option>
</select>
Thanks.
Add an ng-disabled="$ctrl.model" will disable the select until the "x" clears the $ctrl.model. Once cleared the select will be Reenabled and a new selection can be made.
The only thing I can think of after taking a quick look, is to convert from ng-options to and use ng-disabled on the actual option element. The documentation says that you can hide disabled options, so if for example you were to select OPTION1 and OPTION[2-4] were disabled, they would be removed from the list.
I found a plunker with version 1.0 but it doesn't work. Making options distabled still shows them in the list, although it makes them undefined when you select them. Maybe a newer version is updated to actually remove them.

React Semantic Ui dropdown set dynamically

I am using react-semantic-ui
Here is the scenario:
I have two (2) dropdowns with placeholders, I am setting the 2nd Dropdown's option dynamically when I choose from the 1st dropdown. Then I would choose an item from the 2nd dropdown.
Then, If I changed the value of the 1st dropdown, it should change the values of the 2nd dropdown again, I have no problems with that but I want to set the placeholder back again
Summary: First I chose an item from the 1st dropdown, that sets the options of the 2nd dropdown. Then I choose an item from the 2nd dropdown, then I choose AGAIN from the 1st dropdown and that resets the options of the 2nd dropdown but that placeholder is not showing anymore.

Dropdowns in AngularJS

I have angularjs interdependable dropdowns, here is a demo plunker: http://plnkr.co/edit/mIFCKKO5Azr4ljyoge5r?p=preview. Now when I select an option from first(country) dropdown, I want the second (state)dropdown to be displayed as a checkbox dropdown and not the normal dropdown(like in the above plunker) and after selecting option from second multiple dropdown I should get another multiple dropdown again. Here is a sample checkbox dropdown, fiddle: https://jsfiddle.net/michaeldeongreen/22et6sao/9/ need this to be displayd for both state and city dropdowns in my plunker.
Finally when I select a country from first normal dropdown, the second multiple dropdown menu with checkbox for selecting a state should be enabled and after selecting a state, another checkbox dropdown menu for selecting city have to be enabled. Until I select an option from first dropdown, the second and third dropdowns have to be disabled and till I select option from second dropdown third dropdown has to be disabled.
Hope anyone will help me. Thanks in advance!!

Categories