Results 1 to 6 of 6

Thread: [CLOSED][3.0.0] ComboBox forceSelection is not used in setValue()

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1

    Default [CLOSED][3.0.0] ComboBox forceSelection is not used in setValue()

    Ext version tested:
    • Ext 3.0.0 GA
    Adapter used:
    • ext
    Description:
    • When setting ComboBox value using setValue() there is no check if forceSelection was installed. So I can set nonexistent value.
    See this URL : http://extjs.com/deploy/dev/docs/sou...boBox-setValue


    The result that was expected:
    • When forceSelection is 'true', setValue() should not set nonexistent value.
    The result that occurs instead:
    • No matter if forceSelection is true, it the value always sets.
    Proposed solution:
    • In Ext.form.ComboBox add check for forceSelection property:

      Code:
      setValue : function(v){
              var text = v;
              if(this.valueField){
                  var r = this.findRecord(this.valueField, v);
                  if(r){
                      text = r.data[this.displayField];
                  }else if(Ext.isDefined(this.valueNotFoundText)){
                      text = this.valueNotFoundText;
                  }
              }
      
              if(this.forceSelection && !r){
                  this.clearValue();
              }else{
                  this.lastSelectionText = text;
                  if(this.hiddenField){
                      this.hiddenField.value = v;
                  }
                  Ext.form.ComboBox.superclass.setValue.call(this, text);
                  this.value = v;
              }
              return this;
          },

  2. #2
    Sencha User mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,232

    Default

    i think you've misunderstood the purpose of forceSelection
    -- it only controls end-user/UI interaction, not programmatic manipulation.

  3. #3

    Default

    Ok. But it's worth to add another configuration property for this purpose. I've just created SelectBox widget from ComboBox using setValue() function mentioned above.

    There exists another related issue:
    If I use
    Code:
        editable: false
    then i should also add
    Code:
        listeners: {
            beforequery: function (e) {
                e.query = '';
            }
        }
    Or the combo won't show full items list if i select any.

  4. #4
    Sencha User mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,232

    Default

    Quote Originally Posted by bbg View Post
    Ok. But it's worth to add another configuration property for this purpose. I've just created SelectBox widget from ComboBox using setValue() function mentioned above.
    can't comment on that.
    someone will probably need to put up a feature request on that.

    Quote Originally Posted by bbg View Post
    There exists another related issue:
    If I use
    Code:
        editable: false
    then i should also add
    Code:
        listeners: {
            beforequery: function (e) {
                e.query = '';
            }
        }
    Or the combo won't show full items list if i select any.
    that's because the combo is configured with triggerAction: 'query' by default (see the docs for more info).
    for non-editable combos, you'll probably want to set triggerAction: 'all'.
    no need for that beforequery listener you have there.

  5. #5

    Default

    Thanks for your help, friend!
    I eager to see the next revision of Ext available for free download

  6. #6
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    Marking this as closed, what Marc has said is correct.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •