Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49226

How does Picker refresh the data for each column?

$
0
0

@chuck_don wrote:

code

let picker = this.pickerCtrl.create();
    picker.addButton({
      text: '取消',
      role: 'cancel'
    });
    picker.addButton({
      text: '确定',
      handler: (data: any) => {
        this.value = data;
        console.log(data);
      },
    });
    let province = china.province[0].value,
      city = china.city[province][0].value;
    picker.addColumn({ name: 'province', options: china.province });
    picker.addColumn({ name: 'city', options: china.city[province] });
    picker.addColumn({ name: 'area', options: china.area[city] });
    picker.ionChange.subscribe(info => {
      if (province != info.province.value) {
        province = info.province.value;
        for (let _info of china.province) {
          if (_info.value == province) {
            picker.getColumn('city').options = china.city[province];
            picker.getColumn('city').selectedIndex = 0;
            city = china.city[province][0].value;
            picker.getColumn('area').options = china.area[city];
            picker.getColumn('area').selectedIndex = 0;
            break;
          }
        }
        picker.refresh();
      }

      if (city != info.city.value) {
        city = info.city.value;
        picker.getColumn('area').options = china.area[city];
        picker.getColumn('area').selectedIndex = 0;
        picker.refresh();
      }
    });
    picker.isOverlay = false;
    picker.present();

After switching, the code changes the array of the city, and this problem occurs

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>