1. #1
    Sencha User
    Join Date
    Jun 2011
    Location
    India
    Posts
    35
    Vote Rating
    3
    tanmayasahu is on a distinguished road

      0  

    Default Answered: Combobox Should have a option for don't fire the change Event when using setValue()

    Hi ExtJS Dev Team,
    I am facing a issue with combobox setValue() method. My requirement is not to fire the change event of combobox, when I am setting the value using setValue(). Any way I have solved the problem by overriding the the setValue() method. But I think it is better to give a optional boolean parameter in the setValue() to use or avoid the change event.

    Thanks...

  2. Please see the following:

    Code:
    Ext.application({
        name : 'Fiddle',
    
        launch : function() {
    
            var states = Ext.create('Ext.data.Store', {
                fields: ['abbr', 'name'],
                data : [
                    {"abbr":"AL", "name":"Alabama"},
                    {"abbr":"AK", "name":"Alaska"},
                    {"abbr":"AZ", "name":"Arizona"}
                ]
            });
            
            var combo = Ext.create('Ext.form.ComboBox', {
                fieldLabel: 'Choose State',
                store: states,
                queryMode: 'local',
                displayField: 'name',
                valueField: 'abbr',
                renderTo: Ext.getBody()
            });
            
            combo.on('change', function(combo){
               console.log('--- change ---'); 
               console.log(combo.getValue()); 
            });
            
            combo.setValue('AK');
            
            setTimeout(function(){
                console.log('--- set raw ---'); 
    	        combo.setRawValue('AZ');
    	        console.log(combo.getValue()); // value, but no change event
            },1000);
    
        }
    });

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,263
    Vote Rating
    486
    Answers
    696
    scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute

      0  

  4. #3
    Sencha User
    Join Date
    Jun 2011
    Location
    India
    Posts
    35
    Vote Rating
    3
    tanmayasahu is on a distinguished road

      0  

    Default SetRawValue() is for setting the displayValue

    Hi Scott,
    SetRawValue() is for setting the displayValue, it will not change the value field of the combo am I right ?
    I want the value of the combobox will get changed and the change event should not fire.

    Thanks
    Tanmaya

  5. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,263
    Vote Rating
    486
    Answers
    696
    scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute scottmartin has a reputation beyond repute

      0  

    Default

    Please see the following:

    Code:
    Ext.application({
        name : 'Fiddle',
    
        launch : function() {
    
            var states = Ext.create('Ext.data.Store', {
                fields: ['abbr', 'name'],
                data : [
                    {"abbr":"AL", "name":"Alabama"},
                    {"abbr":"AK", "name":"Alaska"},
                    {"abbr":"AZ", "name":"Arizona"}
                ]
            });
            
            var combo = Ext.create('Ext.form.ComboBox', {
                fieldLabel: 'Choose State',
                store: states,
                queryMode: 'local',
                displayField: 'name',
                valueField: 'abbr',
                renderTo: Ext.getBody()
            });
            
            combo.on('change', function(combo){
               console.log('--- change ---'); 
               console.log(combo.getValue()); 
            });
            
            combo.setValue('AK');
            
            setTimeout(function(){
                console.log('--- set raw ---'); 
    	        combo.setRawValue('AZ');
    	        console.log(combo.getValue()); // value, but no change event
            },1000);
    
        }
    });

  6. #5
    Sencha User
    Join Date
    Jun 2011
    Location
    India
    Posts
    35
    Vote Rating
    3
    tanmayasahu is on a distinguished road

      0  

    Default

    Hi Scott, Thanks for sharing the example, Actually I was passing the raw value to the setRawValue() method. That was my mistake.....

Thread Participants: 1

Tags for this Thread