下面是用用戶數據填充的filteringSelect示例。我的目標是對顯示的值執行wilcard匹配。例如,如果用戶鍵入'son',下拉式匹配將是「homer simpSON'和'carl calSON'。 默認情況下,匹配只會在標籤的開頭dojo.FilteringSelect如何配置爲匹配通配符值?
我試過改變dijit .byId( 'userselect')。searchAttr,但將其設置爲任何東西,但一個字符串引起erronious行爲。
<input id="userselect">
<script type="text/javascript">
dojo.require("dijit.form.FilteringSelect");
dojo.require("dojo.data.ItemFileReadStore");
var user_data = {
"itentifier":"user_id",
"label":"label",
"items":[
{"first_name":"Waylon","last_name":"Smithers","label":"Waylon Smithers","user_id":7}
,{"first_name":"Carl","last_name":"Carlson","label":"Carl Carlson","user_id":6}
,{"first_name":"Homer","last_name":"Simpson","label":"Homer Simpson","user_id":4}
,{"first_name":"Lenny","last_name":"Leonard","label":"Lenny Leonard","user_id":5}
,{"first_name":"Montgomery","last_name":"Burns","label":"Montgomery Burns","user_id":8}
]
};
dojo.addOnLoad(function() {
var userStore = new dojo.data.ItemFileReadStore({
//url: "/user/lookup",
data: user_data
});
var filteringSelect = new dijit.form.FilteringSelect({
id: "userselect",
name: "userselect",
store: userStore,
searchAttr: 'label' //["first_name", "last_name", "oasis"]
},
"userselect");
});
</script>
queryExpr工作,但現在的匹配的行爲是錯誤的: 想我開始鍵入「辛普森」中,第一個字符'現在匹配'Waylon Smithers',組合字段填入'Waylon Smithers',但突出顯示是錯誤的。當我繼續輸入'imson'時,它將選定的文本合併爲「wimpson」,然後不會匹配 這是一個錯誤在dojo? – AntiEgo 2010-05-11 15:02:12
據我瞭解你必須將它設置爲* $ {0}。你做到了嗎? – kalkin 2010-05-12 10:57:50