先移除,后添加
Ext.create('Ext.form.Panel', {
title: 'Simple Form',
bodyPadding: 5,
width: 350,
layout: 'anchor',
defaults: {
anchor: '100%'
},
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
name: 'first',
allowBlank: false
},{
fieldLabel: 'Last Name',
name: 'last',
allowBlank: false
}],
buttons: [{
text: 'Change',
handler: function() {
var form=this.up('form'),last=form.getForm().findField('last');
form.remove(last);
form.add({xtype:'combo',fieldLabel:'change'});
}
}],
renderTo: Ext.getBody()
});