如何将 queryExpr 用于 dijit/form/ComboBox

How to use queryExpr for dijit/form/ComboBox

我有组合框 dijit/form/ComboBox,我希望当用户开始输入时组合框显示包含字母的结果。

例如组合框有这个值

当用户键入 "D" 结果应该是

如果组合 select 项目包含搜索关键字,只需使用 queryExpr: "*[=12=]*" 进行搜索即可。

下面是使用最后一个的完整示例:

require([
    "dojo/store/Memory", "dijit/form/ComboBox", "dojo/domReady!"
], function(Memory, ComboBox){
    var stateStore = new Memory({
        data: [
            {name:"", id:""},
            {name:"Nebraska", id:"NE"},
            {name:"South Dakota", id:"SD"},
            {name:"Delaware", id:"DE"},
            {name:"Test1", id:"T1"},
            {name:"Test2", id:"T2"},
            {name:"Test3", id:"T3"}
        ]
    });

    var ComboBox = new ComboBox({
        id: "filteringCombo",
        store: stateStore,
        queryExpr: "*[=10=]*",
        searchAttr: "name"
    }, "filterCombo").startup();
});
<script type="text/javascript">
  dojoConfig = {isDebug: true, async: true, parseOnLoad: true}
</script>

<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>
<link href="//ajax.googleapis.com/ajax/libs/dojo/1.8.3/dijit/themes/claro/claro.css" rel="stylesheet"/>
<body class="claro">
  <div id="filterCombo"></div>
</body>