1. #1
    Ext JS Premium Member
    Join Date
    Nov 2008
    Posts
    285
    Vote Rating
    3
    wki01 is on a distinguished road

      0  

    Default ComboBox and onSelect and validateValue

    ComboBox and onSelect and validateValue


    My code:
    Code:
    Ext.Wki.ComboBox = Ext.extend(Ext.form.ComboBox, {
         initComponent:function() {
             Ext.Wki.ComboBox.superclass.initComponent.call(this); 
         }, 
         onSelect: function(record, index) {   
             this.clearInvalid()
             Ext.Wki.ComboBox.superclass.onSelect.apply(this, arguments);
             return true;     
         },
     validateValue : function(value){
          if (this.allowBlank == false && value.trim() == "") {
             this.markInvalid()
             return false;
          }
          return (Ext.Wki.ComboBox.superclass.validateValue.call(this, value))
     }
    });
    I would like to force the field to be valid if I select an item from the combo despite the rules of validation.

    How can I prevent the validateValue be launched after the onSelect?

    Thank you

  2. #2
    Sencha User BitPoet's Avatar
    Join Date
    Sep 2008
    Location
    Bavaria
    Posts
    277
    Vote Rating
    1
    BitPoet is on a distinguished road

      0  

    Default


    How about just checking whether there is a selection in validateValue?
    Code:
      ...
      validateValue: function(value) {
        if( this.view.getSelectionCount() > 0 ) {
          return true;
        }
        if( this.allowBlank == false ...

Thread Participants: 1