[wijmo-5.20203.766] AutoComplete数据源来自ItemsSourceFunction时
theComboBox.selectedItem拿不到, selectedValu也拿不到, 只有textlet theComboBox = new input.AutoComplete('#theComboBox', {
displayMemberPath: 'chdh', searchMemberPath: 'chdh', selectedValuePath: 'chdh', headerPath: 'chdh', selectedValue: "001", isRequired: false
, minLength: 1, async itemsSourceFunction(query, max, callback) {
const {state, data, msg} = {"data":[{"czy":"张三","chdh":"001","sj":null,"dcck":"上海二号仓","drck":"上海一号仓","id":5,"wfstate":null,"resid":null,"wfid":null}],"state":0};
if (state === 0) callback(data)
else layer.alert(msg ? msg : '查询失败')
}
});
你好,为什么要给itemSourceFunction加async?参考以下代码:
import 'bootstrap.css';
import '@grapecity/wijmo.styles/wijmo.css';
import './styles.css';
//
import * as wijmo from '@grapecity/wijmo';
import * as input from '@grapecity/wijmo.input';
//
document.readyState === 'complete' ? init() : window.onload = init;
//
function init() {
// AutoComplete with async search using OData source
let theAutoComplete = new input.AutoComplete('#theAutoComplete', {
displayMemberPath: 'chdh',
searchMemberPath: 'chdh',
selectedValuePath: 'chdh',
headerPath: 'chdh',
isRequired: false,
minLength: 1,
itemsSourceFunction: (query, max, callback) => {
const {state, data, msg} = {"data":[{"czy":"张三","chdh":"001","sj":null,"dcck":"上海二号仓","drck":"上海一号仓","id":5,"wfstate":null,"resid":null,"wfid":null}],"state":0};
callback(data)
},
selectedIndexChanged: function () {
let product = theAutoComplete.selectedItem;
document.querySelector('#msg').textContent = product
? wijmo.format('{czy} (ID: {chdh})', product)
: 'None';
}
});
}
https://www.grapecity.com/wijmo/demos/Input/AutoComplete/AsyncLoading/purejs
页:
[1]