我有Combobox dijit/form/ComboBox
,我希望当用户开始输入组合框时会显示包含字母的结果。
例如,combox具有此值
当用户键入" D" 结果应该是
答案 0 :(得分:2)
简单地使用queryExpr: "*${0}*"
来搜索组合选择项是否包含搜索关键字。
使用最后一个完整的样本:
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: "*${0}*",
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>
&#13;