Dynamically add form elements in Extjs 4
Code snippet to dynamically add form elements in Extjs 4 with ease.
Ext.onReady(function() {
var myForm = Ext.create('Ext.form.Panel', {
title: 'Query form',
width: 600,
renderTo: Ext.getBody(),
items: [{
xtype: 'button',
text: 'click me to add',
handler: function() {
var tf = Ext.create('Ext.form.field.Text', {
name: 'name',
fieldLabel: 'Name'
});
myForm.add(tf);
}
}]
});
});
I love seeing stuff like this, want to contribute some learning materials to the framework itself? (ed @ sencha com if you're interested)
ReplyDelete