您好,拿AutoComplete的组件示例来讲:
https://demo.grapecity.com.cn/wi ... ete/Overview/purejs
在isDroppedDownChanged事件中,可以判断出当前操作是展开下拉,还是收起下拉;
用s.selectedItem可以判断出当前选中的项,在这里可以判断当选中的是默认项时,自动调整到下一项,如代码所示:
如代码所示:
- isDroppedDownChanged: function(s){
- if(!s.isDroppedDown){
- console.log(s.selectedItem);
- }
- }
复制代码
完整代码:
- 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', {
- placeholder: "请选择",
- displayMemberPath: 'country',
- itemsSource: getData(),
- isDroppedDownChanged: function(s){
- if(!s.isDroppedDown){
- console.log(s.selectedItem);
- }
- }
- });
- }
复制代码 |