Thank you for reporting this bug. We will make it our priority to review this report.
  1. #21
    Sencha User ngrover's Avatar
    Join Date
    Jun 2007
    Location
    Calgary Alberta Canada
    Posts
    24
    Vote Rating
    3
    ngrover is on a distinguished road

      0  

    Default


    Quote Originally Posted by nomatter View Post
    How about something like that (controlled by a parameter in the original ComboBox)?

    Code:
    Ext.define('myapp.SearchCombo', {
        extend: 'Ext.form.ComboBox',
        alias: 'widget.searchcombo',
    
        findRecord: function(field, value) {
            var ds = this.store,
                idx = ds.findExact(field, value);
    
            // lets get the record!
            if(idx === -1) {
                this.store.on('load', Ext.bind(this.setValue, this, [value]), null, {single: true});
                ds.load({
                    params: {
                        id: value
                    }
                });
                return;
            }
    
            return idx !== -1 ? ds.getAt(idx) : false;
        }
    });
    I use this Version to allow setValue without a loaded Store (e.g. when i have a foreign key to some huge dataset in a form record).

    For use in the default ComboBox we would of course need some config params and maybe also some further checks.
    I had to tweak you're solution for ExtJS 4 RC3:

    Code:
      findRecord: function(field, value) {
        var ds = this.store;
        var idx = ds.findExact(field, value);
        if(idx === -1 && !this.initialRecordFound) {
          this.initialRecordFound = true;
          this.store.on({
            load: {
              fn: Ext.Function.bind(function(value) {
                if (this.forceSelection) {
                  this.setValue(value);
                }
                this.store.removeAll();
              }, this, [value]),
              single: true
            }
          });
          ds.load({
            params: {
              id: value
            }
          });
        }
        return idx !== -1 ? ds.getAt(idx) : false;
      }

  2. #22
    Ext JS Premium Member
    Join Date
    Jan 2010
    Location
    San Diego, CA
    Posts
    254
    Vote Rating
    5
    dbrin is on a distinguished road

      0  

    Thumbs up


    Tweaked it just a tad to enable the use of queryParam:
    Code:
     findRecord: function(field, value) {
        var ds = this.store,params ={},
            idx = ds.findExact(field, value);
        if(idx === -1 && !this.initialRecordFound && this.queryMode === 'remote') {
          this.initialRecordFound = true;
          this.store.on({
            load: {
              fn: Ext.Function.bind(function(value) {
                if (this.forceSelection) {
                  this.setValue(value);
                }
                this.store.removeAll();
              }, this, [value]),
              single: true
            }
          });
          params[this.queryParam]=value;
          ds.load({params:params});
        }
        return idx !== -1 ? ds.getAt(idx) : false;
      }
    you can now use it in an override to effect all of you remote loading combos, just wrap the function in
    Code:
    Ext.override(Ext.form.field.ComboBox, {
    ..my overriden function
    });

  3. #23
    Ext JS Premium Member
    Join Date
    Dec 2007
    Posts
    229
    Vote Rating
    0
    ngd is an unknown quantity at this point

      0  

    Default


    @Evant: what is the solution? Is there one yet. It's now 4.1.1.

  4. #24
    Sencha User
    Join Date
    Dec 2010
    Posts
    19
    Vote Rating
    0
    wboard is on a distinguished road

      0  

    Default Workaround

    Workaround


    I still use this as workaround (works fine, http://www.sencha.com/forum/showthre...-setting-value),

    is there any progress in fixing this issue properly??

  5. #25
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    5
    Vote Rating
    0
    pward123 is on a distinguished road

      0  

    Default +1

    +1


    +1 - amazed this bug hasn't been addressed since it was originally reported almost 4 years ago

  6. #26
    Sencha User
    Join Date
    Mar 2013
    Posts
    18
    Vote Rating
    4
    chocis is on a distinguished road

      0  

    Default +1

    +1


    Yeah, this should be implemented by default in ExtJS, because I hate using hacky overrides.

  7. #27
    Sencha Premium Member cmendez21's Avatar
    Join Date
    Jun 2007
    Location
    Mexico D.F.
    Posts
    479
    Vote Rating
    1
    cmendez21 is on a distinguished road

      0  

    Lightbulb workaround so far on ext 4.2.1.883

    workaround so far on ext 4.2.1.883


    So far i encounter the same issue about setValue and the problem is all in : findRecord: function(field, value) {

    Original code:
    Code:
        findRecord: function(field, value) {
            var ds = this.store,
                idx = ds.findExact(field, value);
            return idx !== -1 ? ds.getAt(idx) : false;
        },
    and the problem is I set a Value (int) type and the function search it as text but not by the proper data type according on the MODEL , so i changed so far to this, and worked according my needs , perhaps it needs more work .
    Code:
        findRecord: function(field, value) {         // EDITED BY cmendez21
            var ds = this.store;        
            var Fieldsx = ds.model.getFields(); 
            var tmpval  = undefined; 
            for (var i=0;i<Fieldsx.length;i++){ 
                if (Fieldsx[i].name == field){ 
                    if  (ds.model.getFields()[0].type.type =="int"){ 
                        tmpval = parseInt(value); 
                    } else if  (ds.model.getFields()[0].type.type =="float"){     
                        tmpval = parseFloat(value); 
                    } else { 
                        tmpval = value; 
                    } 
                    break;
                }
            }
            //var idx = ds.findExact(field, value, 0); //Added  0  at the end
            if (tmpval!=undefined){                     
                var idx = ds.findExact(field, tmpval, 0);   //Added  0  at the end          
                return idx !== -1 ? ds.getAt(idx) : false;
            } else { 
                return false; 
            }
        },
    hope this helps for anyone
    E2CS: Extjs - Event calendar solution | XtPrinter
    Calendar Thread | XtPrinter Thread| Blog

  8. #28
    Sencha User
    Join Date
    Jan 2013
    Posts
    5
    Vote Rating
    0
    lawrence_o is on a distinguished road

      0  

    Default


    I had behavior I feel is incorrect but maybe I am missing something?

    Given, window w defining combo c with store s. Store s has autoLoad: true;

    Window w has a method to init form values of which combo c is an item.
    I noticed that when shown, combo c did not have its value set.

    Debugging revealed that combo setValue method has this:

    Code:
    if (me.store.loading) {
             blah blah
    }
    But it appeared that the store.load was not yet called yet is is autoLoad: true!! I did not expect this. I would assume creation of the combo with autoLoad store to have completed and that the store.load would have been called at least before returning the initComponent / constructor calls!

    I guess that changing the above code to

    Code:
    if (me.store.loading || me.store.getCount == 0) {
             blah blah
    }
    would solve the problem... Perhaps by introducing a new config like e.g. deferOnZeroCount or something...

    Thanks for your feedback.
    Kind regards
    Lorenzo

  9. #29
    Ext JS Premium Member
    Join Date
    Jun 2009
    Posts
    249
    Vote Rating
    1
    Hacker-CB is on a distinguished road

      0  

    Default


    When this problem will be fixed?

  10. #30
    Sencha User filippo.ferrari's Avatar
    Join Date
    Apr 2010
    Location
    Sanremo - Italy
    Posts
    126
    Vote Rating
    1
    filippo.ferrari has a reputation beyond repute filippo.ferrari has a reputation beyond repute filippo.ferrari has a reputation beyond repute filippo.ferrari has a reputation beyond repute filippo.ferrari has a reputation beyond repute filippo.ferrari has a reputation beyond repute filippo.ferrari has a reputation beyond repute filippo.ferrari has a reputation beyond repute filippo.ferrari has a reputation beyond repute filippo.ferrari has a reputation beyond repute filippo.ferrari has a reputation beyond repute

      0  

    Default


    When this problem will be fixed? +1