你好,在lostFocus事件中就可以实现,参考代码如下:
- import 'bootstrap.css';
- import '@grapecity/wijmo.styles/wijmo.css';
- import './styles.css';
- //
- import * as input from '@grapecity/wijmo.input';
- import { getData } from './data';
- //
- document.readyState === 'complete' ? init() : window.onload = init;
- //
- function init() {
- let theCombo = new input.ComboBox('#theCombo', {
- displayMemberPath: 'country',
- itemsSource: getData()
- });
- //
- let theAutoComplete = new input.AutoComplete('#theAutoComplete', {
- displayMemberPath: 'country',
- itemsSource: getData(),
- isDroppedDownChanged: function(e){
- console.log(e.listBox.collectionView.items[0]);
- },
- lostFocus: function(e){
- if(e.listBox.collectionView.items.length > 0){
- e.selectedItem = e.listBox.collectionView.items[0];
- }
- }
- });
- }
复制代码
可以把上边的代码拷贝到这个示例中看运行效果:
https://demo.grapecity.com.cn/wi ... ete/Overview/purejs |