import * as React from 'react'; import JqxDropDownList, { IDropDownListProps } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxdropdownlist'; class App extends React.PureComponent<{}, IDropDownListProps> { private myDropDownList = React.createRef(); private mySelect = React.createRef(); private updating: boolean = false; constructor(props: {}) { super(props); this.listOnSelect = this.listOnSelect.bind(this); this.onSelectChange = this.onSelectChange.bind(this); this.state = { selectedIndex: 0 } } public componentDidMount() { this.myDropDownList.current!.loadFromSelect('select'); } public render() { return (
); } private listOnSelect(event: any): void { if (event.args && !this.updating) { const index = event.args.item.index; this.mySelect.current!.selectedIndex = index; } } private onSelectChange() { this.updating = true; const index = this.mySelect.current!.selectedIndex; this.setState({ selectedIndex: index }, () => { this.myDropDownList.current!.ensureVisible(index); this.updating = false; }); } } export default App;