PDA

View Full Version : Problem by getting the value of a combo in a tbar



Shining77
22 Sep 2010, 9:26 AM
Hello !!

My problem is the following one:

I have integrated a combo in a tbar of a TabPanel like this:

xtype: 'combo',
store: adminsCombo,
id: 'adminCombo',
hiddenName: 'adminId',
valueField: 'id',
displayField: 'name',
typeAhead: true,
mode: 'local',
triggerAction: 'all',

On the right side of this combo I have placed a button in the tbar with the following handler:

Ext.get('adminCombo').getValue()
...

But now I am getting the displayField-Value.
Is it also possible to get the valueField-Value?

troseberry
22 Sep 2010, 9:48 AM
Your problem is with the Ext.get() method. It is getting the elements underlying value as it is in the DOM. Try this.



Ext.getCmp('adminCombo').getValue();

troseberry
22 Sep 2010, 9:51 AM
I would however suggest checking out the following forum posting
http://www.sencha.com/forum/showthread.php?103569-Ext.getCmp-and-developers-using-it-as-a-crutch

The solution using the Ext.getCmp() method will work but there are better ways to structure your code so that you dont have to use this method. However in the end you have to use what works for you.