找回密码
 立即注册

QQ登录

只需一步,快速开始

张天笑

注册会员

15

主题

25

帖子

179

积分

注册会员

积分
179
张天笑
注册会员   /  发表于:2021-3-5 10:35  /   查看:4171  /  回复:1
1金币
theComboBox.selectedItem拿不到, selectedValu也拿不到, 只有text
let 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 : '查询失败')
    }
});

1 个回复

倒序浏览
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2021-3-5 11:15:22
沙发
你好,为什么要给itemSourceFunction加async?参考以下代码:
  1. import 'bootstrap.css';
  2. import '@grapecity/wijmo.styles/wijmo.css';
  3. import './styles.css';
  4. //
  5. import * as wijmo from '@grapecity/wijmo';
  6. import * as input from '@grapecity/wijmo.input';
  7. //
  8. document.readyState === 'complete' ? init() : window.onload = init;
  9. //
  10. function init() {
  11.     // AutoComplete with async search using OData source
  12.     let theAutoComplete = new input.AutoComplete('#theAutoComplete', {
  13.         displayMemberPath: 'chdh',
  14.         searchMemberPath: 'chdh',
  15.         selectedValuePath: 'chdh',
  16.         headerPath: 'chdh',
  17.         isRequired: false,
  18.         minLength: 1,
  19.         itemsSourceFunction: (query, max, callback) => {
  20.             const {state, data, msg} = {"data":[{"czy":"张三","chdh":"001","sj":null,"dcck":"上海二号仓","drck":"上海一号仓","id":5,"wfstate":null,"resid":null,"wfid":null}],"state":0};
  21.             callback(data)
  22.         },
  23.         selectedIndexChanged: function () {
  24.             let product = theAutoComplete.selectedItem;
  25.             document.querySelector('#msg').textContent = product
  26.                 ? wijmo.format('{czy} (ID: {chdh})', product)
  27.                 : 'None';
  28.         }
  29.     });
  30. }
复制代码


https://www.grapecity.com/wijmo/ ... AsyncLoading/purejs
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部