Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#15844 closed defect (invalid)

FilteringSelect throw a CancelError by set(value, '')

Reported by: charly Owned by: Douglas Hays
Priority: undecided Milestone: tbd
Component: Dijit - Form Version: 1.8.0
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by Douglas Hays)

Hello,

when I using fs.set(value,'') to set the value which is backed by a empty json store, firebug throw a CancelError?.

json: {identifier:"value", label:"name", items:[{value:'', name:''}]};

Version 1.8.0 = no error

Version 1.8.0-src = throw error

Version 1.8.0rc1-src = no error

See firebug error:

Firebug cancelError by FilteringSelect when fs.set(value,'')

thx charly

Attachments (1)

CancelError_FilteringSelelect.JPG (68.3 KB) - added by charly 7 years ago.
Firebug cancelError by FilteringSelect? when fs.set(value,)

Download all attachments as: .zip

Change History (15)

Changed 7 years ago by charly

Firebug cancelError by FilteringSelect? when fs.set(value,)

comment:1 in reply to:  description Changed 7 years ago by charly

Replying to charly:

Hello,

when I using fs.set(value,'') to set the value which is backed by a empty json store, firebug throw a CancelError?.

json: {identifier:"value", label:"name", items:[{value:'', name:''}]};

dojo-release-1.8.0 = no error

dojo-release-1.8.0-src = throw error

dojo-release-1.8.0rc1-src = no error

See firebug error:

No image " CancelError_FilteringSelelect.JPG" attached to CancelError

thx charly

comment:2 Changed 7 years ago by Douglas Hays

Description: modified (diff)

comment:3 Changed 7 years ago by Douglas Hays

Owner: changed from Douglas Hays to charly
Status: newpending

Please provide a small testcase. Also, are you using dojox.data.JsonRestStore or dojo.store.JsonRest or ItemFileReadStore or something else?

comment:4 Changed 7 years ago by charly

Status: pendingnew

json-data-fs.json:

{ 
  "identifier": "value", 
  "label": "name", 
  "items": [  { "value": "AL", "name": "Alabama", "label": "Alabama" }, 
              { "value": "AK", "name": "Alaska", "label": "Alaska" },
              { "value": "AZ", "name": "Arizona", "label": "Arizona",},
              { "value": "AR", "name": "Arkansas", "label": "Arkansas" },
              { "value": "CA", "name": "California", "label": "California",},
              { "value": "CO", "name": "Colorado", "label": "Colorado" },
              { "value": "CT", "name": "Connecticut", "label": "Connecticut" }
            ]
}
<html>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<script type="text/javascript" src="/JavascriptLibraries/dojo-release-1.8.0-src/dojo/dojo.js"
   data-dojo-config="async: true, parseOnLoad: true, isDebug: true, useCommentedJson: true, locale:'en-us'">
</script>

<link rel="stylesheet" type="text/css" href="/JavascriptLibraries/dojo-release-1.8.0-src/dijit/themes/tundra/tundra.css" >

</head>

<body class="tundra">
<form>
<div data-dojo-type="FilterReadStoreEX" 
                  data-dojo-id="store_div"
                  data-dojo-props="url:'json-data-fs.json',
                                  requestMethod:'get',
                                  doClientPaging:'true',
                                  doClientSorting:'false'">
</div> 
            
<input id="fs"
        name="filteringSelect" 
        data-dojo-type="dijit.form.FilteringSelect"  
        data-dojo-props="store:store_div,
                         placeHolder:'Search',
                         searchDelay:400,
                         searchAttr:'name',
                         labelAttr:'name',
                         highlightMatch:'all',
                         required:false,
                         autoComplete:false, 
                         labelType:'text',
                         hasDownArrow:false,
                         trim:true,
                         fetchProperties:{minInputLength:1}"> 

<script>

require(["dojox/data/QueryReadStore",         
         "dojo/domReady!"],
        
  function(){
/**************************************************
 * declare class
 * ************************************************/
dojo.provide("FilterReadStoreEX");
dojo.declare(
    "FilterReadStoreEX",
    dojox.data.QueryReadStore,
    {              
      /** CHANGE WIDGET_ID */
      widgetId: 'fs',
      
      /** CHANGE DATA_DOJO_ID */
      dataDojoId: 'store_div',
     
      fetch:function(request) {
       
        var myWidget = dijit.byId(this.widgetId);
       
        var requestTextname = request.query.name.replace(/\*$/,"");    
        var textLength = requestTextname.length;
        var minInputLength = request.minInputLength;
           
        //control input length 
        if(textLength < minInputLength){
          
          var listBoxValue = '';            
          var dataJson = {identifier:"value", label:"name", items:[{value:listBoxValue, name:listBoxValue}]};
          var dataStore = new dojo.store.Memory({data: dataJson});
          
            //reset textbox
            if(textLength == 0 && !myWidget.hasDownArrow){
            
              //trigger onChange event
              myWidget.store = dataStore;
              myWidget.set('value', listBoxValue);
              myWidget.store = dojo.eval(this.dataDojoId);
              
              
            }//if

          //No request please, do nothing.  
          return this;
          
        }//if
        
        return this.inherited("fetch", arguments); 
      }//fetch
    
    
	   }//declare
	);//FilterReadStoreProject

});//require

</script>

</form>

</body>
</html>

I think "return this;" is the problem. But I don't need request, when I set widget to empty string.

comment:5 Changed 7 years ago by charly

when you clear the input box and after you click outside the box, you get the error message by firebug.

comment:6 Changed 7 years ago by Douglas Hays

Owner: changed from charly to Douglas Hays
Status: newassigned

comment:7 Changed 7 years ago by Douglas Hays

Resolution: invalid
Status: assignedclosed

By not calling this.inherited from fetch, you bypassed the code that calls request.onBegin(total); request.onComplete(results);, both of which are needed by FilteringSelect?

comment:8 Changed 7 years ago by charly

It should be possible to stop the fetch by "return".

How can i use request.onBegin. Can you provide a example, please.

comment:9 Changed 7 years ago by Douglas Hays

These are documented in the dojo.data API. You can browse the file dojo/data/api/Read.js
It would be something like request.onBegin(0); request.onComplete([]); for no items being returned.

comment:10 Changed 7 years ago by charly

I try this,

request.onComplete([]);
return this.inherited("fetch", arguments); 

but it doesn't work.

comment:11 Changed 7 years ago by Douglas Hays

Oddly you left out request.onBegin(0); Also, if you call this.inherited then you shouldn't be calling either onBegin or onComplete since they'll be called there as well.

comment:12 Changed 7 years ago by charly

I try instead of "return this;".

request.onBegin(0);

and

return request.onBegin(0);

and

request = null;

and

return request = null;

and

this.fetch = null;

but nothing is working.

comment:13 Changed 7 years ago by Douglas Hays

request.onBegin(0);
request.onComplete([]);
return this;

comment:14 Changed 7 years ago by charly

Yes, it works.

Thank you very much.

Note: See TracTickets for help on using tickets.