我们正在平面列表中创建多个动态选择器控件。一个动态控件的onchange事件,需要填充另一个动态选择器控件的选择器项。
handleDynamicOptions = (item, index) => {
var type = item.item.type
var field name=item.item.OptionLevelName
var OptionLevelId=item.item.OptionLevelId
if (type.toUpperCase() == 'LIST') {
var optionlist = [];
for (let i = 0; i < this.state.dynamicoptionlist[1].list.length; i++)
{
// console.log("ListNames:" + JSON.stringify(final_array[1].list[i]))
var id = this.state.dynamicoptionlist[1].list[i].OptionLevelId;
if (OptionLevelId==id) {
optionlist =this.state.dynamicoptionlist[1].list[i].list;
}
}
console.log("OptionList:"+JSON.stringify(optionlist))
return (
<View style={{ flex: 0.5, margin: 5 }} key={index}>
<Text style={{ marginBottom: 5 }}>{fieldname}</Text>
<View style={styles.dropdownlist}>
<Picker style={{ marginTop: -6, marginBottom: -6 }}
mode='dropdown' key="jop1"
selectedValue={this.state[fieldname]}
onValueChange={(itemValue, itemIndex) => this.onPickerValueChange([fieldname], itemValue)}
>
{optionlist.map((item, i) => {
return <Picker.Item key={i} value={item.OptionId} label={item.OptionName} />
})}
</Picker>
</View>
</View>
)
}