raychenfj / ion-multi-picker

Multi Item Picker - An Ionic Custom Multi Picker Component
https://raychenfj.github.io/ion-multi-picker/
Other
236 stars 103 forks source link

Can't set columns from ancestor to child #51

Closed wuzhiji37 closed 7 years ago

wuzhiji37 commented 7 years ago
this.columns = [
      {
        name: 'ancestor',
        options: [
          { text: '1', value: '1' },
          { text: '2', value: '2' }
        ]
      },
      {
        name: 'parent',
        parentCol: 'ancestor',
        options: [
          { text: '1-1', value: '1-1', parentVal: '1' },
          { text: '1-2', value: '1-2', parentVal: '1' },
          { text: '2-1', value: '2-1', parentVal: '2' },
          { text: '2-2', value: '2-2', parentVal: '2' },
        ]
      },
      {
        name: 'child',
        parentCol: 'parent',
        options: [
          { text: '1-1-1', value: '1-1-1', parentVal: '1-1' },
          { text: '1-1-2', value: '1-1-2', parentVal: '1-1' },
          { text: '1-2-1', value: '1-2-1', parentVal: '1-2' },
          { text: '1-2-2', value: '1-2-2', parentVal: '1-2' },
          { text: '2-1-1', value: '2-1-1', parentVal: '2-1' },
          { text: '2-1-2', value: '2-1-2', parentVal: '2-1' },
          { text: '2-2-1', value: '2-2-1', parentVal: '2-2' },
          { text: '2-2-2', value: '2-2-2', parentVal: '2-2' }
        ]
      }
    ];

the example is ok in my project; then,I change the example to this, and it doesn't work like example.

raychenfj commented 7 years ago

@wuzhiji37 Thanks, there is actually a bug!!!

Temporary workarounds are:

  1. Forget About the parentCol, default its order is from left to right

  2. Or try to add another attribute alias, and give it the same value as parentCol

     {
        name: 'child',
        parentCol: 'parent',
        alias: 'parent',
        ...    
      }
wuzhiji37 commented 7 years ago

thank you! I use the solution 1 and it works