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

Hiding/disabling selected items in the dropdown for multi select feature

Open aniruddhadas9 opened this issue 7 years ago • 5 comments

Is there a was we can disable or hide(remove from the list) from the dropdown list incase its already selected. it its de selected then it will added again.

currently its in grey color and on clicking of the selected item (normally user try to select) it de select the item from the list. But some time user want not to see the selected item while selecting.

is there a way to do this for multi select

aniruddhadas9 avatar Aug 23 '17 16:08 aniruddhadas9

The simple way is to use CSS to do that.
So you should have something like that:

ng-select /deep/ select-dropdown .selected {
    display: none
}

lukashpvp avatar Aug 24 '17 11:08 lukashpvp

in my component i added below line which have ng-select component but it did not work. I think you have added encapsulation: ViewEncapsulation.Native and its not taking external css. But when I put the same below line in my style.scss (I am using angular-cli) it work perfectly.

 .selected {
    display: none
}

I think you should allow others to add css to select component level

aniruddhadas9 avatar Aug 24 '17 21:08 aniruddhadas9

encapsulation is set to ViewEncapsulation.None

select select-dropdown

basvandenberg avatar Aug 25 '17 09:08 basvandenberg

Maybe the css statement:

.selected {
    display: none
}

is not specific enough? Have you tried the following as well?

ng-select select-dropdown .selected {
    display: none
}

basvandenberg avatar Sep 23 '17 13:09 basvandenberg

I have to place this css in my style.scss file rather inside the component scss file worked for me

// style.scss file in angular cli project
/*tags component inside of the ng-select and ng-select-dropdown*/
/*this is a fix for the ng-select component because they did not have viewencapsulation in there compoenent*/
select-dropdown {
  .options {
    ul {
      li.selected {
        display: none;
      }
    }
  }
}

aniruddhadas9 avatar Oct 02 '17 18:10 aniruddhadas9