PDA

View Full Version : Show selected record in textfield



neosky
13 Dec 2013, 3:21 AM
Hello, i have store with fields :


fields: [
{name: 'id', type: 'int'},
{name: 'Name', type: 'string'},
{name: 'All', type: 'string'},

and view where i have form with combobox and textfield, and in combobox i select name from store:


xtype: 'combobox',
name: 'people_name',
fieldLabel: 'People',
store: 'Name.Store',
displayField: 'Name',
svalueField: 'code',
width: 400,
editable: false,
value: '<select name>',

i want: when i am select name in combobox in textfield automatically show 'id' from store which corresponds with name in combobox. thanks

scottmartin
17 Dec 2013, 10:16 AM
See if this is what you are looking for



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 panel = Ext.create('Ext.panel.Panel', {
bodyPadding: 5,
title: 'Form',
renderTo: Ext.getBody(),
items: [{
xtype: 'combo',
fieldLabel: 'Combo',
store: states,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
listeners: {
select: function(combo){
var tf = combo.up('panel').down('#tfid');
tf.setValue(combo.getValue());
}
}
}, {
xtype: 'textfield',
fieldLabel: 'Field 3',
itemId: 'tfid'
}],
});

}
});

neosky
18 Dec 2013, 9:45 PM
thank you scottmartin (http://www.sencha.com/forum/member.php?165873-scottmartin) very much you helped me again! :)