2010-02-01 35 views
2

我有一個jsp頁面,其中包含一個由連接到後端java服務器的dojo.data.ItemFileReadStore填充的dijit.form.ComboBox。它的工作方式與預期一致,組合框可以正確顯示結果。問題是我收到一個'dojo.data.ItemFileReadStore:無效的項目參數。'當使用鍵盤箭頭鍵在結果列表中滾動時。然而用鼠標選擇工作正常。dojo.data.ItemFileReadStore:與Dijit組合框無效的項目參數

道場版本1.2.3

這是怎麼了,我已經把它在的地方我的jsp:

<input type="text" id="value" 
dojoType="dijit.form.ComboBox" 
autoComplete="false" 
searchAttr="name" 
forceValidOption="true" 
hasDownArrow="false" 
onKeyUp="populateValue" 
/> 

<script type="text/javascript"> 
function populateValue() { 
    valueWidget = dijit.byId("value"); 
    var selectedValue = valueWidget.getValue(); 
    var url = "${contextPath}/someUrl?selectedValue=" + selectedValue + "%"; 
    store = new dojo.data.ItemFileReadStore({url:url}); 
    valueWidget.store = store; 
    return; 
    } 
</script> 

下面是我從服務器接收的JSON:

{"items":[ 
    {"name":"My string 1","label":"My string 1"}, 
    {"name":"My string 2","label":"My string 2"}, 
    {"name":"Mev.","label":"Mev."}], 
"identifier":"name"} 

任何想法這裏怎麼回事?

回答

2

解決了它。問題似乎是組合框上的onKeyUp事件。當我將其更改爲onKeyPress時,向下滾動列表不會產生更多錯誤。

與onKeyUp相比,onKeyPress實際上延遲了一個字符,因爲事件在字符實際上未被輸入時觸發。任何想法我怎麼能克服這個?

+0

謝謝!它解決了它。但爲什麼發生這種事情不明白 – 2011-10-31 11:15:57

+0

@NeelBasu你終於解決了這個問題?你找到原因了嗎? – MockerTim 2013-08-27 11:16:50

+0

好吧,這是一個2歲的故事,我不記得我在做什麼:) – 2013-08-27 18:37:52