Filtering Select with QueryReadStore: no selection

I use dijit.form.FilteringSelect, supported dojox.data.QueryReadStore, so that the user can select a region (think about automatic completion). On each character entered by the user, QueryReadStoresends a request to the server, waiting for a list of json matches (with corresponding identifiers). By the time a fairly short list is displayed, the user selects the desired item. [Admittedly, asking for every keystroke is not the most efficient template, but at the moment it’s good enough.]

Unexpected behavior: in some rare but special cases, the choice made by the user "does not stick." For example, if the user enters " can", she is offered the following options in the following order:

Atlantic Canada
Canada
English Canada
Lower Canada
Upper Canada
Western Canada

If she chooses " Canada" among them, dijit closes the drop down selection by choosing her choice correctly. But by the time the user leaves the field, the selection will switch to " Atlantic Canada"!

This strange phenomenon occurs systematically for a small number of specific regions. (First, I thought that the common factor between those who misbehaved was that their name contained accented characters or hyphens, but obviously not with the Canadian example. So far, I do not see a regular pattern.)

. , , dojo, , dojo: ? , ? ? ( Firebug), ? .

dojo 1.1.1, dojo 1.2.3.

() FilteringSelect:

new dijit.form.FilteringSelect({
   name = "region";
   autoComplete = false;
   hasDownArrow = false;
   labelAttr = "name";
   queryExpr = "${0}";
   store = new dojox.data.QueryReadStore({url:'/query/regions'});
}, myNode);

EDIT (2009/02/18):

, , . , FilteringSelect onChange onBlur, :

  • : can
  • 6 ( ).
  • , "Canada" ( 1)
  • Enter ( ). , "Canada" . :

    onChange event: region 1
    
  • , tab. , :

    onBlur event: region 1
    onChange event: region 246
    

(Region 246 is Atlantic Canada.) ... , (onBlur), Canada . ...

+3
6

, . - , FilteringSelect QueryReadStore. QueryReadStore , json, - .

, FilteringSelect , Store (QueryReadStore ) , . FilteringSelect , . , , . .

, FilteringSelect , Store , , , . , , FilteringSelect , , .

, QueryReadStore . ( ) FilteringSelect , Store , . " *", asteriks - .

, QueryReadStore slighlty :

  • :/query/regions? name = signedString * & start = 0 & count = 5
  • :/query/regions? name = String & start = 0

, " ". .

, . , .

+2

, Dojo 1.1.1 1.2.0.

, FilteringSelect , , , .

, ( , ), .

() : http://www.nabble.com/Problems-with-QueryReadStore-td19269498.html.

:

FilteringSelect, , , .

, , , :

 <select id="coffee2" name="coffee2" 
    dojotype="dijit.form.FilteringSelect" 
    autoComplete="false">
    <script type="dojo/method" event="onChange"  args="newValue">
        console.log(dijit.byId('coffee2').getValue() + '/' + dijit.byId('coffee2').getDisplayedValue());
    </script>
    <option value="0">AAA</option>
    <option value="1">AAA</option>
    <option value="2">AAA</option>
    <option value="3">AAA</option>
    <option value="4">AAA</option>
  </select>

-, , .

+2

, ! , .

dijit.form.filteringSelect, dojox.data.QueryReadStore, , db, ( ). , , , , db , . Zend Framework, QueryReadStore , autocompletelistAction.

, Damelin, autocompletelisteAction, QueryReadStore, GET .

char:

$txt = (String) $this->_request->getParam('parameter');
$lastChar = substr($txt, -1);

, 1 char , $txt :

if ((strlen($txt) >= 1) && ($lastChar != '*')) {
  // here, the parameter is the full text, which the user selected by
  // clicking on a shown element of the filteringSelect

  // Therefore, I "explode" the parameter to correspond to my searched values
  // and I build my SQL LIKE clauses without "%"
  // Consequence? There is only one result which is the good one.
}
else {
  // here, the parameter is a "part" of the search, which the user typed in

  // Therefore, I build my SQL LIKE clauses with "%$txt%"
}
// Here I can just launch my SQL queries with the built LIKE clauses
// and return result(s) to the QueryReadStore

, $txt char? Zend Framework "" filteringSelect , ( ), "" .

, , PHP- .

, damelin , dojo .

+1

pnt...

, : "", QueryReadStore , DisplayedValue .

"Canada". , (. ) , ( , ), FilteringSelect --- "Atlantic Canada".

, , ( ) , .

0

. , _setDisplayedValueAttr FilteringSelect.js, :

_setDisplayedValueAttr: function(/*String*/ label, /*Boolean?*/ priorityChange){ return }

, , , .

- _callbackSetLabel:

this._setValueFromItem(result[0], priorityChange);

. , .

Hope this worked for you, we are using the trunk version of FilteringSelect.js, by the way (http://trac.dojotoolkit.org/browser/dijit/trunk/form/FilteringSelect.js)

0
source

" , , QueryReadStore ..."

There is a filteringSelect searchDelay attribute that you can set that waits for a given number of milliseconds before sending a request.

0
source

All Articles