PDA

View Full Version : How to dinamically Populate textarea after combobox select



gigofizz
9 Mar 2012, 7:53 AM
How to dinamically Populate textarea with (description) after combobox select (title_description).


{ xtype: 'combo',
name: 'tsm_codigo',
fieldLabel: "Template SMS",
emptyText: "Selecciona Template SMS",
store: 'ListTempSms',
queryMode: 'local',
valueField: 'tsm_codigo',
displayField: 'tsm_titulo',
listeners: {
select : function() {
var tsmcod = Ext.getCmp('tsm_codigo').getValue();
var smsmen = Ext.getCmp('sms_mensaje');

smsmen.store.reload({params: {tsm_codigo: tsmcod}});
Ext.DomHelper.overwrite('sms_mensaje', smsmen);
}
}
},{
xtype: 'textarea',
fieldLabel: "Mensaje",
id : 'sms_mensaje',
name : 'tsm_mensaje',
store: 'ListTempSms',
queryMode: 'local',
valueField: 'tsm_codigo',
displayField: 'tsm_mensaje',
enableKeyEvents: true
}


Thank you for your help in this matter.

tobiu
9 Mar 2012, 8:14 AM
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.field.TextArea-method-setValue

gigofizz
13 Mar 2012, 11:11 AM
'select': function(combo, value){
var locationcopy = combo.up('form').down('textarea[name=sms_mensaje]');
locationcopy.setValue(value[0].data.tsm_mensaje);
}
Solution good.
Could we have done better?

ramana_l_v
13 Mar 2012, 11:41 AM
I have a similar question, what is the correct way for getting the locationcopy component, is it the way done above or defining an id value and getting the component by Ext.getCmp(<idvalue> ?

Thanks

gigofizz
13 Mar 2012, 11:48 AM
Use Ext.getCmp('sms_mensaje').setValue(value[0].data.tsm_mensaje); in the examples is the correct. But not a good practice.
I'm wrong?