I'm working on a SharePoint Webpart and I have a Dropdown, which works fine, but when I reload the page, it shows no item in the dropdown field. When I open the list and select some item, it will be presented.
and
I want to reset the Dropdown to default valu " * Bitte wählen." How is it possible? I have a Description Text under my list, and I can reset it.
Here is my code too:
<div className={styles.choice}><br></br>
<Dropdown options={ this.state.options }
onChange={ this.handleChange }/>
</div>
<textarea id= "infoText" readOnly value={this.state.selectedValue} className={styles.infoText} placeholder= "Option aus der Rubrik wählen"></textarea>
public handleChange = (event: FormEvent<HTMLDivElement>, option: IDropdownOption): void => {
this.setState({
selectedOption: option.text,
selectedValue: option.key.toString()
});
}
public addListItem = ():void => {
let dropdown = option.text;
// item push in the SharePoint List
pnp.sp.web.lists.getByTitle("TestList")
.items.add({
'Rubrik': dropdown
})
.then(()=> alert("Die Datei wurde erfolgreich gespeichert!"));
}
}
}
Any Idea? Thank you!