valor-software / ng2-select

Angular based replacement for select boxes
http://valor-software.github.io/ng2-select/
MIT License
675 stars 586 forks source link

ng2-select with children not working in 1.2.0 #753

Open TheBurgerShot opened 7 years ago

TheBurgerShot commented 7 years ago

Hi All,

In my application ng2-select does not show any suggestions when i'm using grouped data. I know that my syntax is correct, because without changing anything in my code it works fine when I install version 1.1.2.

Anyone else experiencing this? If so, as I mentioned, downgrading to 1.1.2 worked for me. If anyone knows what I could be missing or has a solution I'd like to hear!

Thanks in advance!

psilospore commented 7 years ago

Looks like it doesn't work on their site either http://valor-software.com/ng2-select/

shahjay748 commented 7 years ago

Newer version requires id of parent, so set and it will work. e.g.

  
public items:Array<any> = [
    {
      id: 1,
      text: 'India',
      children: [
        {id: 54, text: 'Mumbai'}
      ]
    },
    {
      id: 2,
      text: 'USA',
      children: [
        {id: 2, text: 'New York'},
        {id: 9, text: 'Washington DC'}
      ]
    }
    ]
  
newerik commented 7 years ago

Adding ID to the elements did solve the issue as @shahjay748 wrote. Thank you!

HigorSilvaRosa commented 7 years ago

Here dont work even with id