-
29 May 2008 8:57 AM #1
[2.1svn2134] empty ComboBox.getValue() returns emptyText in SVN build
[2.1svn2134] empty ComboBox.getValue() returns emptyText in SVN build
It appears that the changes made in SVN revision 2134 to Ext.form.Field are causing an empty ComboBox's value to be set to the emptyText value. I didn't look too much into the code that seems to have caused this, but I believe it's a change made to the afterRender method.
Here's some simple code to reproduce the bahavior I'm experiencing, although I'm sure it could be duplicated using any example with a TextField (or any component derived from Field) that has the emptyText property defined.
Running the above with the SVN build, both Ext.getCmp('testCombo').value and Ext.getCmp('testCombo').getValue() return 'Select One...'. The same in Ext 2.1 returns ''.Code:Ext.onReady(function(){ Ext.QuickTips.init(); var combo = new Ext.form.ComboBox({ id: 'testCombo', emptyText: 'Select One...', typeAhead: true, triggerAction: 'all', mode: 'local', store: new Ext.data.SimpleStore({ fields: [ {name: 'id'}, {name: 'name'} ], data : [ [1, 'Chevrolet'], [2, 'Volkswagen'], [3, 'Honda'], [4, 'Ford'] ], sortInfo: {field: 'name', direction: 'ASC'} }), displayField: 'name', valueField: 'id', forceSelection: true, allowBlank: false, renderTo: document.body }); var button = new Ext.Button({ text: 'Get Value', renderTo: document.body, handler: function() { Ext.MessageBox.show({ title: 'Hello!', msg: 'The value of the combobox is \'' + Ext.getCmp('testCombo').getValue() + '\'', icon: Ext.MessageBox.INFO, buttons: Ext.MessageBox.OK, animEl: 'testCombo' }); } }); });
Please let me know if you need more info or if I can be of help.
-Rocco
-
9 Jun 2008 1:41 AM #2
Code:Ext.override( Ext.form.ComboBox, { 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(this.valueNotFoundText !== undefined){ text = this.valueNotFoundText; } } this.lastSelectionText = text; if(this.hiddenField && v != this.emptyText){ this.hiddenField.value = v; } Ext.form.ComboBox.superclass.setValue.call(this, text); this.value = v; } });Last edited by mystix; 9 Jun 2008 at 2:16 AM. Reason: use [code][/code] tags
-= miu-miu =-
Linux, Perl, GNU, Open Source, Ajax, Ubuntu 9.04
-
28 Jan 2009 10:15 AM #3
doesnt work.
doesnt work.
Code doesn't work as posted either before or after multiple comboboxes are created. If the solution is only for an application which uses one combobox, can it please be extended for n comboboxes?
-
11 Aug 2011 7:08 AM #4
Combobox.getValue() returns null
Combobox.getValue() returns null
Does any body has a solution to the following problem?
I have combobox on a panel with following combobox code:
{
xtype: 'combobox',
name : 'batchgroup',
fieldLabel: 'Batch Group',
id: 'batchgroup',
store: 'dp.Abc',
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
//forceSelection : true,
editable: false,
autoSelect: true,
emptyText: "<Select Value>",
columnWidth: .5
}
-----------------
Later in the code when i try to get the value using the following code, I get a null value even after a user selects
a value in the above combobx
var batchgroup = Ext.getCmp('batchgroup');
console.log('batchgroup value... '+batchgroup.getValue());
Here the batchgroup.getValue() so retrieved is null


Reply With Quote