ありがとうございます。これは通常、完全に一致するためです。私の奴隷がテキストの中で「好き」だったという事実のため、最初の要素は必ずしも正確なマクトではありません。
私の問題を解決するために、私はFilteringSelect.jsを変更しました。したがって、コンボボックスオプションに完全一致があり、この要素が返されているかどうかをチェックします。私の場合、正確なマッチはコンボボックスのリストの2番目、3番目になります。もし私が最初のものを返すのでなければ(前と同じように)。ここで
コード:
> _callbackSetLabel: function( /*Array*/ result,
/*Object*/ dataObject,
/*Boolean?*/ priorityChange){
// summary:
// Callback function that dynamically sets the label of the
// ComboBox
// setValue does a synchronous lookup,
// so it calls _callbackSetLabel directly,
// and so does not pass dataObject
// still need to test against _lastQuery in case it came too late
if((dataObject && dataObject.query[this.searchAttr] != this._lastQuery) || (!dataObject && result.length && this.store.getIdentity(result[0]) != this._lastQuery)){
return;
}
if(!result.length){
//#3268: do nothing on bad input
//#3285: change CSS to indicate error
this.valueNode.value = "";
dijit.form.TextBox.superclass._setValueAttr.call(this, "", priorityChange || (priorityChange === undefined && !this._focused));
this._isvalid = false;
this.validate(this._focused);
this.item = null;
}else{
//because the combobox have a like of the word the first element may no be the exact match
for(var j = 0; j < result.length; j++) {
//check if in the result there is the text that the user typed
if(dataObject && result[j].i["id"].toLowerCase() === dataObject.query[this.searchAttr].toLowerCase())
{
//return the exact match
this.set('item', result[j], priorityChange);
return;
}
}
// if there isn't a exact match return the first of the list
this.set('item', result[0], priorityChange);
}
},
出典
2011-01-28 00:57:12
ffM